i have this xml schema , what i want is how to extract the values of all the nodes one by one, using XMLStarlet , in shell script
<service>
<imageScroll>
<imageName>Photo_Gallerie_1.jpg</imageName>
</imageScroll>
<imageScroll>
<imageName>Photo_Gallerie_2.jpg</imageName>
</imageScroll>
<imageScroll>
<imageName>Photo_Gallerie_3.jpg</imageName>
</imageScroll>
</service>
xmlstarlet sel -t -m "//imageName" -v . -n your.xml
output:
Photo_Gallerie_1.jpg
Photo_Gallerie_2.jpg
Photo_Gallerie_3.jpg
Is that what you needed?
sel (select mode)-t (output template(this is pretty much required)-m (for each match of the following value)
"// (the double slash means it could be anywhere in the tree)imageName (name of node you want)"-v (requests the value of an element in the current path) and the . represents current element in iteration (you could put the name of the node there but it's generally easier this way)
and then the -n is to add a line for every value you match.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With