You should try these tools :
xmlstarlet
: can edit, select, transform… Not installed by default, xpath1xmllint
: often installed by default withlibxml2-utils
, xpath1 (check my wrapper to have--xpath
switch on very old releases and newlines delimited output (v < 2.9.9)xpath
: installed via perl’s moduleXML::XPath
, xpath1xml_grep
: installed via perl’s moduleXML::Twig
, xpath1 (limited xpath usage)xidel
: xpath3saxon-lint
: my own project, wrapper over @Michael Kay’s Saxon-HE Java library, xpath3
xmllint
comes with libxml2-utils
(can be used as interactive shell with the --shell
switch)
xmlstarlet
is xmlstarlet
.
xpath
comes with perl’s module XML::Xpath
xml_grep
comes with perl’s module XML::Twig
xidel
is xidel
saxon-lint
using SaxonHE 9.6 ,XPath 3.x (+retro compatibility)
Ex :
xmllint --xpath '//element/@attribute' file.xml
xmlstarlet sel -t -v "//element/@attribute" file.xml
xpath -q -e '//element/@attribute' file.xml
xidel -se '//element/@attribute' file.xml
saxon-lint --xpath '//element/@attribute' file.xml
.