Parse xml script using script

hi ,

I my xml I have a particular field like below I want to get the select query and use it in my script again.Sometime the query is very long and have new line also. This is embedded into an xml I have only copied the part I want to extract .

text="select * from dual">
text="select * from xml_config">
text="select * from
         WHERE SOC_STATUS='A') sa,
                        SUBSCRR sub,
                        UH_TEMP_CUSTO leading
                    where   (NVL(SA.EXRATION_DATE,SYSDATE) >= SYSDATE - ${HISTORY_DAYS})
                        AND sub.CUSTOMER_ID=LEADING.CUSTOMER_ID
                        AND sa.AGREEMENT_NO = sub.SUBSCRIBER_NO
                        AND SUB.EFFECTIVE_DATE!=NVL(SUB.EXRATION_DATE,SUB.EFFECTIVE_DATE+1) 
                        ORDER BY sa.AGREEMENT_NO">



output:

value[0] =select * from dual
value[1]=select * from xml_config
value[2]=select * from 
    WHERE SOC_STATUS='A') sa,
             SUBSCRR sub,
             UH_TEMP_CUSTO leading
                 where   (NVL(SA.EXRATION_DATE,SYSDATE) >= SYSDATE - ${HISTORY_DAYS})
                 AND .CUSTOMER_ID=LEADING.CUSTOMER_ID
                 AND sa.AGREEMENT_NO = sub.SUBSCRIBER_NO 
                 AND SUB.EFFECTIVE_DATE!=NVL(SUB.EXRATION_DATE,SUB.EFFECTIVE_DATE+1) 
                 ORDER BY sa.AGREEMENT_NO

---thanks

try this,

#!/usr/bin/perl

use strict;
my($str,$i,@a);

open(FH,"select.xml") or die "Fail-$!\n";
while(<FH>) {
chomp;
if (m/text="/ .. /">/) {
if (/^text/) {
        s/^text\="//g;
        s/\"\>$//g;
        push(@a,$_);
} else {
        s/\"\>$//g;
        $str=pop @a;
        push(@a,$str." ".$_." ");
}
}
}
for($i=0;$i<=$#a;$i++) { print "val[$i]=$a[$i]\n";}
close(FH);
awk '!/>$/{s=s" "$0;next}{print s $0}' inputfile | awk '{sub(/text/, "Value["i++"]")sub(/>|^ /,"");print}' > outfile