Cognitionis
The little I know

XMLStarlet


The commandline utility to handle libxml2 standard library.

Important commands:

Select:

xmlstarlet sel -t -c “/elements/result[position()=1]/descrip”

-t      obligatory parameter to use XSLT XPATH templates

-v     value of  –> prints only the value –> excludes xml tags of the selected tag (aaaaa aa aa)

-c   copy of —> prints a copy of the selected element (<a>) –> do not exclude nothing (<a>aaaaa <b>aa</b> aa</a>)

validate XML:

xmlstarlet val -w example.xml

count elements: