extract xml from the command line

I just discovered this morning this cool utility in my /bin directory : xmllint

You can use it to extract values from your xml files within your shell scripts


$ cat foo.xml


John


Jack


$ echo 'cat //emplist/emp[@no="1"]/ename/text()'|
xmllint --shell foo.xml |
sed -n 3p
John

I like this !

5 Comments

Leave a Reply