read and write to xml file

hi

i am quite new to shell scripting and need help in reading and writing in xml file

i have an xml file with format:

 
<main>
    <store>
        <name>ABC</name>
        <flag>0</flag>
        <size>123<size>
    </store>
    <store>
        <name>DEF</name>
        <flag>1</flag>
        <size>234<size>
    </store>
</main>

there are multiple <store> in the xml file

i want to get the following :

  1. value of <name> tag for all <store> with <flag> tag value as 0 into a variable one by one for further processing.

2.i need to get the name of the <store> with <flag> value 0 and least <size> value

  1. How to update the <flag> and <size> value for each <name>

Thanks in advance

Hi kichu,

What have you tried so far?

hi,

i am able to get all the flag values using this

awk -F '</?flag>' '{print $2}' storagedetails.xml

but i am not able to get the <name> one by one into variable for all flag value = 0