psykoblast psykoblast - 6 months ago 43
Bash Question

skip XML element with xmllint

I have following XML :

<Type1 name="">
<Type2 name="">
<Type3 name="">
<finalType name="">
<element value=""/>

I would like to reach the value of element in the
, usually I write :

echo //root/Type1/Type2/Type3/finalType /element@ xmllint etc...

BUT in my application the finalType can be in Type1 or Type2 ! ,so I'm looking for something like that

echo //root/***/finalType /element@ xmllint etc...

but unfortunately it doesnt work ..
Do you have any idea How to "skip" the Type1 , Type2 ... ?


Just use the double slash (or descendant::):

echo ls /root//element            | xmllint --shell file.xml
echo ls /root/descendant::element | xmllint --shell file.xml