xmlstarlet

extracting nodes values with xmlstarlet


I have this XML schema, what I want is how to extract the values of all the <imageName> 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>

Solution

  • that was the solution that i found and it did perfectly the job.

    imagescroller=`xmlstarlet sel -t -m "//root/services/service/imageScroll[rank_of_the_desired_item]" -v imageName -n myfile.xml
    

    sorry for late.