xmlstarlet
A normative exhaustion of every possible
Extract element value constraint by sibling condition:
x=$(xml sel -t -v "//elem/node[type='face']/../desc" root.xml)
The above extracts the desc
element value if node
and desc
are siblings and node
has a type
child node with value face
. The parent of the two siblings is elem
.
Extract element value constraint by element attribute value
xml sel -t -v "//node[@n='123']/type" root.xml
Extract element value constraint by element attribute presence
Extract element value constraint by element attribute presence
xml sel -t -v "//node[not(@n)]/type" root.xml
Extract element value constraint by parent element
Extract element value constraint by parent element attribute
Extract element value constraint by child element
Extract element constraint by its value
Count elements
Count elements having any of the above constraint
Last updated
Was this helpful?