Live data from Hacker News

Show HN: Xq – command-line XML and HTML beautifier and content extractor

github.com

21–30 of 36 posts

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#21

doesn't seem to work great with https://ap-playerservices.streamtheworld.com/api/livestream?station=NOVA_919&version=1.9 so xqilla and learning xlst et al still seems like my to-go for complex documents

Hadn’t heard of XQilla, but looks like it’s limited to XPath 2.

You should try an XPath 3 based implementation. XQuery 3.1 has some nice features not found in XPath 2 implementations e.g. native JSON support, the arrow operator (piping), group by clause in FWLORs. XSLT 3.0 has some nice new stuff too, but I use that less

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#23
post #15
post #11

Shoutout to my go-to: https://github.com/EricChiang/pup#readme (also golang) and my 2nd favorite https://xmlstar.sourceforge.net/

Definitely seconding pup, love it and it's easy to use with css selectors. Often use it to parse HTML tables of data on random websites into usable CSVs / etc. xq looks interesting for pure XML, will add it to my notes. Regarding xmlstarlet, I don't use it much but here's some stuff from my notes: XML filter on xpath: xmlstarlet sel -t -c configuration/appender logback.xml; echo XML editing: xmlstarlet ed -d configur…

using `xmlstarlet` to generate XPATHs to visualize document structure

https://github.com/TomConlin/xpath2dot

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#24
post #21

doesn't seem to work great with https://ap-playerservices.streamtheworld.com/api/livestream?station=NOVA_919&version=1.9 so xqilla and learning xlst et al still seems like my to-go for complex documents

Hadn’t heard of XQilla, but looks like it’s limited to XPath 2. You should try an XPath 3 based implementation. XQuery 3.1 has some nice features not found in XPath 2 implementations e.g. native JSON support, the arrow operator (piping), group by clause in FWLORs. XSLT 3.0 has some nice new stuff too, but I use that less

I would switch but, finding a simple binary that does what I want (input -> complex query -> output) is so frustrating. Everything is a framework or library.

Thankfully XQilla has its own json support which was all I needed so far

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#25

Neat! Like Jq but for XML and HTML. Have you considered adding css sectors as an alternative to xpath? For many simple things a css selector is easer to write and more people already know them. I believe it's possible to translate css selectors to xpath so it wouldn't need another selection engine.

[deleted]

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#27
post #11

Shoutout to my go-to: https://github.com/EricChiang/pup#readme (also golang) and my 2nd favorite https://xmlstar.sourceforge.net/

The pup readme looks pretty great, but a heads up that the project has had limited activity over the past few years. Several raised issues about problems compiling with latest Go releases.

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#28
post #11

Shoutout to my go-to: https://github.com/EricChiang/pup#readme (also golang) and my 2nd favorite https://xmlstar.sourceforge.net/

The pup readme looks pretty great, but a heads up that the project has had limited activity over the past few years. Several raised issues about problems compiling with latest Go releases.

Yeah, 234 forks is not a good look, but that said `brew install -s pup` with `go version go1.19.3 darwin/amd64` reports a-ok so I'd guess it just doesn't have a `go.mod` like normal go developers are used to, and that's why the brew formula moves it into the old style GOPATH setup: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/...

Re: Show HN: Xq – command-line XML and HTML beautifier and content extractor

#30
post #29

curl https://news.ycombinator.com/ | xq yields: Hacker News XML syntax error on line 4: element closed by 1

According to the README on Github main page for the project, you need to provide the -m flag when working with HTML.

— The tool parses XML by default, which is much stricter than HTML. Hence the error you are seeing (in HTML5, one can omit various close tags and the HTML is still 100% valid — that's what you are encountering here)

HTH

Post reply on HN