Earlier quoted context omitted.
There is XPath 3.1: https://www.w3.org/TR/xpath-31/#id-lookup It is more verbose, like you get the size of something with array:size or map:size functions, so it is more readable I am implementing it in Xidel 0.9.9+: http://www.videlibri.de/xidel.html
XPath is really useful and `xmlstarlet` is/was jq before jq existed. These days it's relatively rare to get data in XML instead of JSON, though.
xmlstarlet supports XPath 1, but the W3C did not stop there. They made XPath 2 featuring variables, lists and regular expressions, XPath 3 featuring higher order function, and finally XPath 3.1 featuring JSON support.
For example,
echo '[{"a": 1}, {"a": 2, "b": 3}, {"c": 4}]' | xidel - -e '?*?a!(. * 100)'
will print 100 and 200.Or the same with a verbose syntax:
echo '[{"a": 1}, {"a": 2, "b": 3}, {"c": 4}]' | xidel - -e 'for $obj in array:flatten(.) return map:get($obj, "a") * 100'