xmlstarlet select value xmlstarlet select value xml xml

xmlstarlet select value


The key is to start from the ITEM node, not the identifyer:

$ xmlstarlet sel -t -c "/DATA/TABLES/ITEM[identifyer/@V=1234]" test.xml<ITEM>  <identifyer V="1234"/>  <property1 V="abcde"/>  <Property2 V="qwerty"/></ITEM>

Then you can pick out the bits you want:

$ xmlstarlet sel -t -c "/DATA/TABLES/ITEM[identifyer/@V=1234]/*" test.xml<identifyer V="1234"/><property1 V="abcde"/><Property2 V="qwerty"/>$ xmlstarlet sel -t -v "/DATA/TABLES/ITEM[identifyer/@V=1234]/Property2/@V" test.xmlqwerty