5 ms·
XPath is the real killer feature for parsing XML. I don't think it's possible to use it in this particular example, but in the more generally useful cases wher
by rwmj 6y ago
XPath is the real killer feature for parsing XML. I don't think it's possible to use it in this particular example, but in the more generally useful cases where you want to pull (eg) all subnodes with key matching a particular string, XPath is great.
Here's it being used in real code (search for "xpath_"):
https://github.com/libguestfs/virt-v2v/blob/master/v2v/parse_ovf_from_ova.ml https://github.com/libguestfs/virt-v2v/blob/master/v2v/parse...
https://github.com/libguestfs/virt-v2v/blob/master/v2v/parse_libvirt_xml.ml https://github.com/libguestfs/virt-v2v/blob/master/v2v/parse...
- giobox 6y agoJSONPath confers pretty much the same concept onto JSON too with much the same syntax. There are JPath implementations for most languages now. > https://github.com/json-path/JsonPath https://github.com/json-path/JsonPath
- kstrauser 6y agoJMESPath is similar: https://jmespath.org https://jmespath.org