3 ms·
I recently had to consume an xml service; it would've been great to have something like Jq for xml. For some reason I wasn't really interested in xml -> json c
by platz 12y ago
I recently had to consume an xml service; it would've been great to have something like Jq for xml. For some reason I wasn't really interested in xml -> json conversion as a first step. I also found a bunch of xml cli tools, but they are older, had to learn things like XQuery (which actually few tools today seem to support).
- xaduha 12y agoWell there's XProc. But as with everything XML - you shouldn't really edit it by hand without proper editor support at the very least (preferably DTD/XML Schema aware).
- platz 12y agoI understand XML has namespaces, but I'm not sure what "edit by hand" means in this context. The tools I found previously were xqilla and xmlstarlet, but they seem pretty old and just not as convienient as Jq. I still think there is space for an XML cli tool that is more convenient for the majority of common tasks working with XML, at simply treating the data as a hierarchical structure, without requiring an interface that is full fully-qualified/needs XSLT/etc..
- kstrauser 12y agoFor me, that "some reason" is normally the overlap between children and parameters: <foo bar="123" baz="456"><qux>789</qux></foo> There's not a great round-trip mapping of that to JSON, like: {"foo": {"bar": 123, "baz": "456", "children": {"qux": 789}}} (which also illustrates why I dislike XML being untyped unless you have a schema file to interpret it with).
- jeroenjanssens 12y agoI have found `xmlstarlet` to be really useful for working with XML. You can achieve a lot with some basic XPath expressions. No need to learn XSLT. (I should actually update my book Data Science at the Command Line to include this tool.)