3 ms·
Shoutout to my go-to: https://github.com/EricChiang/pup#readme https://github.com/EricChiang/pup#readme (also golang) and my 2nd favorite https://xmlstar.source
by mdaniel 4y ago
Shoutout to my go-to: https://github.com/EricChiang/pup#readme https://github.com/EricChiang/pup#readme (also golang) and my 2nd favorite https://xmlstar.sourceforge.net/ https://xmlstar.sourceforge.net/
- tmsbrg 4y agoDefinitely 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 configuration/root -d configuration/logger -s configuration -t elem -n woof -v 'Woof!' logback.xml The last one deletes elements given by xpath "configuration/root" and "configuration/logger", then adds a new element with the contents <woof>Woof!</woof> under the xpath "configuration".
- mdaniel 4y ago> Regarding xmlstarlet, I don't use it much but here's some stuff from my notes: It is also handy doing at some PoC work, and then one can feed it "-C" to output the backing xslt for use elsewhere $ echo '<a><b>hello</b></a>' | xmlstarlet sel -t -m /a -c 'count(*)' --nl 1 $ echo '<a><b>hello</b></a>' | xmlstarlet sel -C -t -m /a -c 'count(*)' --nl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output omit-xml-declaration="yes" indent="no"/> <xsl:template match="/"> <xsl:for-each select="/a"> <xsl:copy-of select="count(*)"/> <xsl:value-of select="' '"/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
- tejtm 4y agousing `xmlstarlet` to generate XPATHs to visualize document structure https://github.com/TomConlin/xpath2dot https://github.com/TomConlin/xpath2dot
- fbdab103 4y agoThe 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.
- mdaniel 4y agoYeah, 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/pup.rb#L27 https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/...
- nerdponx 4y ago234 forks might be 234 contributors and PRs!