Shell script to extract data in repeating tags from xml

Hi,

I am new to shell scripting. I need to extract data between repeating tags from an xml file and store the data in an array to process it further.

<ns1:root xmlns:ns1="http://example.com/config">

<ns1:interface>in1</ns1:interface>

<ns1:operation attribute1="true" attribute2="abd" >
<ns1:tag1>test</ns1:tag1>
<ns1:tag2>test</ns1:tag2>
</ns1:operation>

<ns1:operation attribute1="true" attribute2="abd" >
<ns1:tag1>test1</ns1:tag1>
<ns1:tag2>test1</ns1:tag2>
</ns1:operation>

</ns1:root>

I need to extract the data in the operation tag to an array and later process each of the tags further. Can some one please help me to write a bash script for this?

Thanks
Sai.

Hi,

What have you tried so far and where did you get stuck?

I was able to do it with perl script.

while ($string =~ /<ns1:operation(.*?)<\/ns1:operation>/sg) 
{
    $count++;
    push(@array1,"$1");
}

Thanks.