XML to Text file Parsing Using shell scripting

Hi,
I want to parse an XML File using Shell Script preferably by using awk command,
I/P file is :

<gn:ExternalGsmCell id="016P3A">
                <gn:attributes>
                    <gn:mnc>410</gn:mnc>
                    <gn:mcc>310</gn:mcc>
                    <gn:lac>8016</gn:lac>
                    <gn:bcchFrequency>677</gn:bcchFrequency>
                    <gn:ncc>3</gn:ncc>
                    <gn:bcc>4</gn:bcc>
                    <gn:userLabel>016P3A</gn:userLabel>
                    <gn:cellIdentity>50031</gn:cellIdentity>
                </gn:attributes>
                <xn:VsDataContainer id="016P3A">
                    <xn:attributes>
                        <xn:vsDataType>vsDataExternalGsmCell</xn:vsDataType>
                        <xn:vsDataFormatVersion>EricssonSpecificAttributes.11.03</xn:vsDataFormatVersion>
                        <es:vsDataExternalGsmCell>
                            <es:maxTxPowerUl>100</es:maxTxPowerUl>
                            <es:qRxLevMin>100</es:qRxLevMin>
                            <es:individualOffset>0</es:individualOffset>
                            <es:bandIndicator>1</es:bandIndicator>
                            <es:parentSystem>SubNetwork=ONRM_RootMo_R,vsDataExternalGsmPlmn=GSMPLMN_310_410_3</es:parentSystem>
                            <es:mncLength>3</es:mncLength>
                        </es:vsDataExternalGsmCell>
                    </xn:attributes>
                </xn:VsDataContainer>
</gn:ExternalGsmCell>
............

Pattern continues for diff Id's

The output should be like

GsmCell id    mnc    mcc    lac    bcchFrequency    ncc    bcc    cellIdentity    maxTxPowerUl    qRxLevMin    individualOffset    bandIndicator    mncLenght
016P3A        410    310    8016    677        3    4    50031        100        100        0            1        3

Any Help would be greatly appreciated.

i put only to find three values. for other values, just extend the awk

 
$ nawk -F"[\"<>]" '/ExternalGsmCell id/{id=$3}/mnc/{m=$3}/mcc/{mc=$3} {if(id && m && mc){print id,m,mc; id=m=mc=0;}}' input.txt
016P3A 410 310

wow that was really fast. if time permits i need one more help below is one more xml file with diff pattern i tried it but dint get it , iam sure its a peice of cake for you.

<xn:MeContext id="LSVLKY001">
                    <xn:ManagedElement id="1">
                        <un:RncFunction id="1">
                            <un:UtranCell id="KYLSU17A">
                                <un:attributes>
                                    <un:localCellId>10071</un:localCellId>
                                    <un:uarfcnUl>862</un:uarfcnUl>
                                    <un:uarfcnDl>1087</un:uarfcnDl>
                                    <un:primaryScramblingCode>361</un:primaryScramblingCode>
                                    <un:primaryCpichPower>315</un:primaryCpichPower>
                                    <un:maximumTransmissionPower>416</un:maximumTransmissionPower>
                                    <un:primarySchPower>-18</un:primarySchPower>
                                    <un:cId>10071</un:cId>
                                    <un:secondarySchPower>-35</un:secondarySchPower>
                                    <un:bchPower>-31</un:bchPower>
                                    <un:lac>15913</un:lac>
                                    <un:rac>13</un:rac>
                                    <un:sac>10071</un:sac>
                </un:attributes>
                                <xn:VsDataContainer id="KYLSU17A">
                                    <xn:attributes>
                                    <es:cellReserved>1</es:cellReserved>
                                    <es:administrativeState>1</es:administrativeState>
                                   </xn:attributes>
                                </xn:VsDataContainer>
                            </un:UtranCell>
            </un:RncFunction>
                    </xn:ManagedElement>
                </xn:MeContext>

The xml file has the following lines in the file
There are n number of Mecontext id loops
there are y number of utrancell id loops in each Mecontext loop.
I deleted some unwanted data. i want the output to be in the following format

RNC   UtranCell   cId   uarfcnUl   uarfcnDl   primaryScramblingCode   primaryCpichPower   maximumTransmissionPower   primarySchPower   secondarySchPower   bchPower   lac   rac   sac   cellReserved   administrativeState 
                             LSVLKY53RNC01   KYLSUTOY6552C   65523   862   1087   3   337   446   -18   -35   -31   15913   13   65523   1   1       
LSVLKY53RNC01   KYLSUTOY6552B   65524   862   1087   3   337   446   -18   -35   -31   15913   13   65523   1   1       
LSVLKY53RNC01 TNLSUTOY2018T 20183   862   1087   3   337   446   -18   -35   -31   15913   13   65523   1   1       
SNJNLIDCR0R03   PRSJUTOY0051Y   51   812   1037   246   337   446   -18   -35   -31   51799   255   51   1   1
SNJNLIDCR0R03   PRSJUTOY0051X   51   812   1037   246   337   446   -18   -35   -31   51799   255   51   1   1