Extract Multivalue from XML


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract Multivalue from XML
# 1  
Old 01-06-2012
Extract Multivalue from XML

I have below attached xml file , how can I have my desired output as below.
i/p file

Code:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse xmlns:ns2="http://webservices.fs.com"><aggregates><axes><axis><name>COLUMNS</name><positions><position><members><member><depth>1</depth><dimensionName>AsOfDate</dimensionName><displayName>05-01-2012</displayName><levelName>AsOfDate</levelName><path><items><item>AllMember</item><item>05-01-2012</item></items></path></member><member><depth>0</depth><dimensionName>Measures</dimensionName><displayName>contributors.COUNT</displayName><levelName>Measures</levelName><path><items><item>contributors.COUNT</item></items></path></member></members></position></positions></axis><axis><name>ROWS</name><positions><position><members><member><depth>1</depth><dimensionName>LCSBook</dimensionName><displayName>CBD</displayName><levelName>LCSBook</levelName><path><items><item>AllMember</item><item>CBD</item></items></path></member><member><depth>1</depth><dimensionName>Filename</dimensionName><displayName>TRISS_FXCB.csv</displayName><levelName>Filename</levelName><path><items><item>AllMember</item><item>TRISS_FXCB.csv</item></items></path></member></members></position><position><members><member><depth>1</depth><dimensionName>LCSBook</dimensionName><displayName>CBD</displayName><levelName>LCSBook</levelName><path><items><item>AllMember</item><item>CBD</item></items></path></member><member><depth>1</depth><dimensionName>Filename</dimensionName><displayName>hvar_RGRPD_10D_HVBRUCD_KGR_PROD.xml</displayName><levelName>Filename</levelName><path><items><item>AllMember</item><item>hvar_RGRPD_10D_HVBRUCD_KGR_PROD.xml</item></items></path></member></members></position><position><members><member><depth>1</depth><dimensionName>LCSBook</dimensionName><displayName>CBD</displayName><levelName>LCSBook</levelName><path><items><item>AllMember</item><item>CBD</item></items></path></member><member><depth>1</depth><dimensionName>Filename</dimensionName><displayName>hvar_RGRPD_10D_SV_HVBRUCD_KGR_PROD.xml</displayName><levelName>Filename</levelName><path><items><item>AllMember</item><item>hvar_RGRPD_10D_SV_HVBRUCD_KGR_PROD.xml</item></items></path></member></members></position><position><members><member><depth>1</depth><dimensionName>LCSBook</dimensionName><displayName>CBD</displayName><levelName>LCSBook</levelName><path><items><item>AllMember</item><item>CBD</item></items></path></member><member><depth>1</depth><dimensionName>Filename</dimensionName><displayName>hvar_RGRPD_1D_HVBRUCD_KGR_PROD.xml</displayName><levelName>Filename</levelName><path><items><item>AllMember</item><item>hvar_RGRPD_1D_HVBRUCD_KGR_PROD.xml</item></items></path></member></members></position></positions></axis></axes><cells><cell><formattedValue>17</formattedValue><ordinal>0</ordinal><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">17</value></cell><cell><formattedValue>75</formattedValue><ordinal>1</ordinal><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">75</value></cell><cell><formattedValue>75</formattedValue><ordinal>2</ordinal><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">75</value></cell><cell><formattedValue>75</formattedValue><ordinal>3</ordinal><value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">75</value></cell></cells></aggregates></ns2:executeMDXResponse></soap:Body></soap:Envelope>

desired o/p
Code:
		                                            5/1/2012
		                                 contributors.COUNT
CBD	TRISS_FXCB.csv	                                      17
	hvar_RGRPD_10D_HVBRUCD_KGR_PROD.xml	75
	hvar_RGRPD_10D_SV_HVBRUCD_KGR_PROD.xml	75
	hvar_RGRPD_1D_HVBRUCD_KGR_PROD.xml	75

# 2  
Old 01-07-2012
use an XML parser in a language like Python, Perl, etc...
# 3  
Old 01-09-2012
thanks frank but I'm looking for some idea in linux itself.
Hope you have something to share.
# 4  
Old 01-09-2012
Is there any reason you don't want to use Perl or Python?
Although it may not be to your liking, you got an accurate and appropriate answer from frank_rizzo. You could roll your own XML parser, but if you can't/don't want to reinvent the wheel, using perl's or pythons XML libs is the easiest way. Just google around, there are a bunch of tutorials out there, and it seems like it may be useful for you, if you think you will encounter this kind of problem more than once.
# 5  
Old 01-09-2012
I don't have perl and python in my system.
Thats the whole reason for it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract a value from an xml file

I have this XML file format and all in one line: Fri Dec 23 00:14:52 2016 Logged Message:689|<?xml version="1.0" encoding="UTF-8"?><PORT_RESPONSE><HEADER><ORIGINATOR>XMG</ORIGINATOR><DESTINAT... (16 Replies)
Discussion started by: mrn6430
16 Replies

2. Shell Programming and Scripting

Extract strings from XML files and create a new XML

Hello everybody, I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings.. The original XML files contain the source code for... (12 Replies)
Discussion started by: milano.churchil
12 Replies

3. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

4. Shell Programming and Scripting

Extract value from XML

I have a file like below <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

5. Shell Programming and Scripting

xml extract problem

I have looked at other responses and never was able to modify to work. data is: <?xml version="1.0"?> <note version="0.3" xmlns:link="http://beatniksoftware.com/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size" xmlns="http://beatniksoftware.com/tomboy"><title>recoll</title><text... (12 Replies)
Discussion started by: Klasform
12 Replies

6. Shell Programming and Scripting

sed extract from xml

I have an xml file that generally looks like this: "<row><dnorpattern>02788920</dnorpattern><description/></row><row><dnorpattern>\+ 44146322XXXX</dnorpattern><description/></row><row><dnorpattern>40XXX</dnorpattern><description/></row><row><dnorpattern>11</dn... (4 Replies)
Discussion started by: garboon
4 Replies

7. Shell Programming and Scripting

XML data extract

Hi all, I have the following xml document : <HEADER><El1>asdf</El1> <El2>3</El2> <El3>asad</El3> <El4>asasdf</El4> <El5>asdf</El5> <El6>asdf</El6> <El7>asdf</El7> <El8>A</El8> <El9>0</El9> <El10>75291028141917</El10> <El11>asdf</El11> <El12>sdf</El12> <El13>er</El13> <El14><El15>asdf... (1 Reply)
Discussion started by: nthed
1 Replies

8. Shell Programming and Scripting

Extract xml data

Hi all, I have the following xml file : <xmlhead><xmlelement1>element1value</xmlelement1>\0a<xmlelement2>jjasd</xmlelement2>...</xmlhead> As you can see there are no lines or spaces seperating the elements, just the character \0a. How can i find and print the values of a specific element?... (1 Reply)
Discussion started by: nthed
1 Replies

9. Shell Programming and Scripting

SED extract XML value

I have the following string: <min-pool-size>2</min-pool-size> When I pipe the string into the following code I am expcting for it to return just the value "2", but its just reurning the whole string. Why?? sed -n '/<min-pool-size>/,/<\/min-pool-size>/p' Outputting:... (13 Replies)
Discussion started by: ArterialTool
13 Replies

10. Shell Programming and Scripting

· simerian · XML Extract

The script following in this thread allows XML data to be located and extracted in a variety of forms from an XML data stream. Using this utility, it is possible to extract all manner of XML subsets and allow data to be post inserted into the "original" XML at any logical point. The pipe is... (2 Replies)
Discussion started by: Simerian
2 Replies
Login or Register to Ask a Question