Search code examples
xmlbashxmlstarlet

Alternative of XML Starlet


Is there any alternative to XML starlet for XML processing in bash? My typical usage is:

  • pretty formatting;
  • selecting data by XPath.

Solution

  • Take a look at xmllint.

    To format xml:

    $ xmllint --format file.xml
    

    To evaluate an XPath:

    $ xmllint --format --shell file.xml <<< "cat /some/xpath/expression"