psykoblast psykoblast - 1 year ago 101
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 ... ?

Answer Source

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

echo ls /root//element            | xmllint --shell file.xml
echo ls /root/descendant::element | xmllint --shell file.xml
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download