xpath - How to select all nodes using xmllint where node on same level has certain value? -


consider following example.xml file

<all>   <item>     <name>foo</name>     <value>5</value>     <readonly>true</readonly>   </item>   <item>     <name>boo</name>     <value>2</value>     <readonly>false</readonly>   </item>   <item>     <name>bar</name>     <value>9</value>     <readonly>true</readonly>   </item> </all> 

i list foo , bar because readonly items. didn't work out me:

cat example.xml | xmllint --xpath "all/item[readonly/text() = "true"]/name" - 

i received:

xpath set empty 

you can try using xpath :

/all/item[readonly='true']/name 

your initial xpath looks given xml posted in question input, may need change double quotes single quotes in xpath parameter value :

--xpath "all/item[readonly/text() = 'true']/name" 

Comments