XML Parse between to tag with upper tag


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting XML Parse between to tag with upper tag
# 1  
Old 03-12-2014
XML Parse between to tag with upper tag

Hi Guys

Here is my Input :

Code:
<?xml version="1.0" encoding="UTF-8"?>
            <xn:MeContext id="01736">
                <xn:VsDataContainer id="01736">
                    <xn:attributes>
                        <xn:vsDataType>vsDataMeContext</xn:vsDataType>
                        <xn:vsDataFormatVersion>EricssonSpecificAttributes.13.25</xn:vsDataFormatVersion>
                        <es:vsDataMeContext>
                            <es:userLabel>01736</es:userLabel>
                            <es:ipAddress>107.69.51.30</es:ipAddress>
                            <es:neMIMversion>vD.1.44</es:neMIMversion>
                            <es:lostSynchronisation>SYNCHRONISED</es:lostSynchronisation>
                            <es:bcrLastChange>1394456163399</es:bcrLastChange>
                            <es:bctLastChange>1394403616793</es:bctLastChange>
                            <es:multiStandardRbs6k>false</es:multiStandardRbs6k>
                            <es:mixedModeRadio>false</es:mixedModeRadio>
                            <es:mirrorMIBversion>D.1.42.M.2.30</es:mirrorMIBversion>
                            <es:stnNodes></es:stnNodes>
                        </es:vsDataMeContext>
                    </xn:attributes>
			<xn:VsDataContainer id="01736_A_111">
                            <xn:attributes>
                                <xn:vsDataType>vsDataEUtranCellFDD</xn:vsDataType>
                                <es:vsDataEUtranCellFDD>
                                    <es:pZeroNominalPusch>-100</es:pZeroNominalPusch>
                                    <es:pZeroNominalPucch>-116</es:pZeroNominalPucch>
                                    <es:dlInterferenceManagementActive>false</es:dlInterferenceManagementActive>
                                    <es:ulInterferenceManagementActive>true</es:ulInterferenceManagementActive>
                                    <es:cellBarred>0</es:cellBarred>
                                    <es:pMaxServingCell>23</es:pMaxServingCell>
                                    <es:systemInformationBlock3>
                                    <es:qHyst>4</es:qHyst>
                                    <es:tEvaluation>240</es:tEvaluation>
                                    <es:tHystNormal>240</es:tHystNormal>
                                    <es:nCellChangeMedium>16</es:nCellChangeMedium>
                                    <es:nCellChangeHigh>16</es:nCellChangeHigh>
                                    <es:qHystSfMedium>0</es:qHystSfMedium>
                                    </es:systemInformationBlock3>
                                    <es:systemInformationBlock6>
                                    <es:tReselectionUtra>2</es:tReselectionUtra>
                                    <es:tReselectionUtraSfMedium>100</es:tReselectionUtraSfMedium>
                                    <es:tReselectionUtraSfHigh>100</es:tReselectionUtraSfHigh>
                                    </es:systemInformationBlock6>
                                    <es:systemInformationBlock7>
                                    <es:tReselectionGeran>2</es:tReselectionGeran>
                                    <es:tReselectionGeranSfMedium>100</es:tReselectionGeranSfMedium>
                                    <es:tReselectionGeranSfHigh>100</es:tReselectionGeranSfHigh>
                                    </es:systemInformationBlock7>
                                    <es:systemInformationBlock8>
                                    <es:searchWindowSizeCdma>8</es:searchWindowSizeCdma>
                                    <es:tReselectionCdmaHrpd>2</es:tReselectionCdmaHrpd>
                                    <es:tReselectionCdmaHrpdSfMedium>100</es:tReselectionCdmaHrpdSfMedium>
                                    <es:tReselectionCdmaHrpdSfHigh>100</es:tReselectionCdmaHrpdSfHigh>
                                    </es:systemInformationBlock8>
                                    <es:mappingInfo>
                                    <es:mappingInfoSIB4>2</es:mappingInfoSIB4>
                                    <es:mappingInfoSIB5>3</es:mappingInfoSIB5>
                                    <es:mappingInfoSIB6>4</es:mappingInfoSIB6>
                                    <es:mappingInfoSIB7>5</es:mappingInfoSIB7>
                                    <es:mappingInfoSIB8>6</es:mappingInfoSIB8>
                                    <es:mappingInfoSIB3>1</es:mappingInfoSIB3>
                                    <es:mappingInfoSIB10>1</es:mappingInfoSIB10>
                                    <es:mappingInfoSIB11>0</es:mappingInfoSIB11>
                                    <es:mappingInfoSIB12>7</es:mappingInfoSIB12>
                                    </es:mappingInfo>
                                    <es:qQualMinOffset>0</es:qQualMinOffset>
                                    <es:rateShapingActive>false</es:rateShapingActive>
                                    <es:threshServingLow>6</es:threshServingLow>
                                    <es:ulSrsEnable>true</es:ulSrsEnable>
                                    <es:acBarringForEmergency>false</es:acBarringForEmergency>
 				</es:vsDataEUtranCellFDD>
    			 </xn:attributes>
                       </xn:VsDataContainer>
             </xn:VsDataContainer>
	 </xn:MeContext>
    </configData>
    <fileFooter dateTime="2014-03-10T10:43:09Z"/>
</bulkCmConfigDataFile>

Output I want is all data between two tag :-

Code:
01736 01736_A_111 vsDataEUtranCellFDD pZeroNominalPusch -100
01736 01736_A_111 vsDataEUtranCellFDD pZeroNominalPucch -116
------
------
01736 01736_A_111 vsDataEUtranCellFDD systemInformationBlock3 qHyst -4
01736 01736_A_111 vsDataEUtranCellFDD systemInformationBlock3 tEvaluation 240
----
----
01736 01736_A_111 vsDataEUtranCellFDD acBarringForEmergency false

I want all value but with respect to 01736 01736_A_111 tag
# 2  
Old 03-12-2014
Does the raw XML actually look like that, or are you copy-pasting prettied-up XML from internet explorer?
# 3  
Old 03-12-2014
No Its Huge XML So i just copy and paste in notepad.

---------- Post updated at 10:59 AM ---------- Previous update was at 10:56 AM ----------

I have Tried below nawk commnad but its have diffrent output and also i have to put all value :

Code:
nawk -F'[\"\>\<]' 'BEGIN{print "Nbr"} /MeContext id/{a=$3} /VsDataContainer id/{b=$3}/cellIndividualOffsetEUtran/{c=$3}/isRemoveAllowed/{d=$3}/isHoAllowed/{e=$3}/loadBalancing/{print a,b,c,d,e,$3}' filename

---------- Post updated at 11:40 AM ---------- Previous update was at 10:59 AM ----------

Any One Can Help me on this ????
# 4  
Old 03-12-2014
The prettied up version is pretty useless. Can you post what it actually looks like?
# 5  
Old 03-12-2014
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
# 6  
Old 03-12-2014
Please find attachment!!!!

Last edited by pareshkp; 03-12-2014 at 11:03 PM..
# 7  
Old 03-12-2014
I like to think this may be easier using xmllint (with --xpath)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grepping multiple XML tag results from XML file.

I want to write a one line script that outputs the result of multiple xml tags from a XML file. For example I have a XML file which has below XML tags in the file: <EMAIL>***</EMAIL> <CUSTOMER_ID>****</CUSTOMER_ID> <BRANDID>***</BRANDID> Now I want to grep the values of all these specified... (1 Reply)
Discussion started by: shubh752
1 Replies

2. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

3. Shell Programming and Scripting

XML files with spaces in the tag name, parse & display?

Greetings all, I have an XML file that is being generated from my application, here is a sample of the first tag (That I am trying to remove and display in a list..) Example- <tag one= "data" data="1234" updateTime="1300"> <tag one= "data1" data="1234" updateTime="1300"> <tag... (5 Replies)
Discussion started by: jeffs42885
5 Replies

4. Shell Programming and Scripting

To search for a particular tag in xml and collate all similar tag values and display them count

I want to basically do the below thing. Suppose there is a tag called object1. I want to display an output for all similar tag values under heading of Object 1 and the count of the xmls. Please help File: <xml><object1>house</object1><object2>child</object2>... (9 Replies)
Discussion started by: srkmish
9 Replies

5. Shell Programming and Scripting

Using shell command need to parse multiple nested tag value of a XML file

I have this XML file - <gp> <mms>1110012</mms> <tg>988</tg> <mm>LongTime</mm> <lv> <lkid>StartEle=ONE, Desti = Motion</lkid> <kk>12</kk> </lv> <lv> <lkid>StartEle=ONE, Source = Velocity</lkid> <kk>2</kk> </lv> <lv> ... (3 Replies)
Discussion started by: NeedASolution
3 Replies

6. Shell Programming and Scripting

Search for a html tag and print the entire tag

I want to print from <fruits> to </fruits> tag which have <fruit> as mango. Also i want both <fruits> and </fruits> in output. Please help eg. <fruits> <fruit id="111">mango<fruit> . another 20 lines . </fruits> (3 Replies)
Discussion started by: Ashik409
3 Replies

7. Emergency UNIX and Linux Support

Trying to parse a xml file for only one tag

I have a xml file in where I need to parse only a particular tag and print the output in the shell script. Here is the tag info in the xml file <dp:file> This is dp file output </dp:file> Output should be printed as This is dp file output. Please help.Thank you. (5 Replies)
Discussion started by: chandu123
5 Replies

8. Shell Programming and Scripting

awk Script to parse a XML tag

I have an XML tag like this: <property name="agent" value="/var/tmp/root/eclipse" /> Is there way using awk that i can get the value from the above tag. So the output should be: /var/tmp/root/eclipse Help will be appreciated. Regards, Adi (6 Replies)
Discussion started by: asirohi
6 Replies

9. Shell Programming and Scripting

How to add the multiple lines of xml tags before a particular xml tag in a file

Hi All, I'm stuck with adding multiple lines(irrespective of line number) to a file before a particular xml tag. Please help me. <A>testing_Location</A> <value>LA</value> <zone>US</zone> <B>Region</B> <value>Russia</value> <zone>Washington</zone> <C>Country</C>... (0 Replies)
Discussion started by: mjavalkar
0 Replies

10. Shell Programming and Scripting

How to retrieve the value from XML tag whose end tag is in next line

Hi All, Find the following code: <Universal>D38x82j1JJ </Universal> I want to retrieve the value of <Universal> tag as below: Please help me. (3 Replies)
Discussion started by: mjavalkar
3 Replies
Login or Register to Ask a Question