extracting nodes values with xmlstarlet -


i have xml schema , want how extract values of nodes 1 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 needed?

sel(sel mode) -t (output template(this pretty required) -m (for each match of following value) "//(the double slash means anywhere in tree) imagename(name of node want)" -v (requests value of element in current path) , "." represents current element in iteration (you put name of node there it's easier way) , -n add line every value you.

hope helps. -dg


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -