I have a file that have lines that contains xml tags. for each line, i want to retrieve the value from the following xml tags and output it to another file with the values only, comma seperated. what is the best way to do this? again, the string is all in 1 line one, though it has many tags.
input : get the values
-------------------------------
<TCRMService><ResponseControl><ResultCode>SUCCESS</ResultCode><ServiceTime>510</ServiceTime><DWLControl><requesterLanguage>100</requesterLanguage><requesterLocale>en</requesterLocale><requesterName>SITE_DM5_070710</requesterName><requestID>1018757</requestID></DWLControl></ResponseControl><TxResponse><RequestType>addCCMSSite</RequestType><TxResult><ResultCode>SUCCESS</ResultCode></TxResult><ResponseObject><TCRMExtension> <TCRMSiteBObj><ComponentID>1000634</ComponentID><SiteId>819128085544095729</SiteId><SitePartyId>S0030Y3ZL6</SitePartyId><ParentOrganizationPartyId>O000Z4M0W3</ParentOrganizationPartyId><MainSiteIndicator>N</MainSiteIndicator><HeadQuarterIndicator>Y</HeadQuarterIndicator><PreferLanguageType>400</PreferLanguageType><PreferLanguageValue>ä¸*文(简体)</PreferLanguageValue><MainBPSiteIndicator>N</MainBPSiteIndicator><ISUCodeType>1000013</ISUCodeType><ISUCodeValue>Global Midmarket Business</ISUCodeValue><DUNSNumber>654642826</DUNSNumber><SiteUsageType>1000001</SiteUsageType><SiteUsageValue>Sold To</SiteUsageValue><CustomerClassificationType>1000005</CustomerClassificationType><CustomerClassificationValue>Commercial Customer</CustomerClassificationValue><BPSiteIndicator>N</BPSiteIndicator><TCRMSiteLastUpdateDate>2010-08-03 17:10:40.957</TCRMSiteLastUpdateDate><TCRMSiteLastUpdateTxId>380128085544090107</TCRMSiteLastUpdateTxId><TCRMSiteLastUpdateUser>SITE_DM5_070710</TCRMSiteLastUpdateUser><DWLStatus><Status>0</Status></DWLStatus><TCRMExtension> <TCRMSiteNameBObj><ComponentID>1000683</ComponentID><SiteNameId>854128085544099140</SiteNameId>
output: to another file with this format.
please see attach response file for example. i'dl like to do this using either awk/sed or perl.
=====================================
I am beginning to understand,can you explain your code? I tried this on my system and it works. I even tried a few more attributes, which works but got really confused as to what all the syntax and commands are doing. Your explanation is greatly appreciated.
ie.
what is (.+?) and (\w+) mean?
ultimately, i'd like to put this in a script instead of running this on the command line. i could potentially expand this to 12 attributes which would be cumbersome on the command line. is there a way to put this in a shell script?
---------- Post updated at 05:06 PM ---------- Previous update was at 04:56 PM ----------
I need to redirect the results to a new file with a new line for every input line that got processed. I tried the code, which is bringing back the correct values - but in the output, it is all in 1 single line. how do I insert a new line into the output for each record that got processed? ie.
---------
rdcwayx, thank you very much!. this code works great. how can i put this in a shell script? I want to call this script whenever, the system generates the input file. Also, can you explain the code?
I'm searching for the names of a TV show in the XML file I've attached at the end of this post. What I'm trying to do now is pull out/list the data from each of the <SeriesName> tags throughout the document. Currently, I'm only able to get data the first instance of that XML field using the... (9 Replies)
Good Day All
Im quiet new to ksh scripting and need a bit of your help. I am attempting to write a script that reads in an XML and extracts certain field values from an XML file. The values are all alphanumeric and consist of two components: e.g "Test 1".
I need to to create a script that... (2 Replies)
Most of my commands are returning this error on RHEL 6 64 bit:
Also I tried installing many sofwtares, but it fails to correctly work. For example I treid installing dos2unix:
# rpm -ivh dos2unix-5.3.3-5.ram0.98.src.rpm
1:dos2unix warning: user mockbuild does not... (0 Replies)
Hi ,
I have a below xml:
<ns:Body>
<ns:result>
<Date Month="June" Day="Monday:/>
</ns:result>
</ns:Body>
i have a lookup abc.txtt text file with below details
Month June July August
Day Monday Tuesday Wednesday
I need a output xml with below tags
<ns:Body>
<ns:result>... (2 Replies)
I've got two different files and want to compare them.
File 1 :
HTML Code:
<response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
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)
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)
Hi,
I have the following code in my xml file:
<aaaRule loginIdPattern=".*"
orgIdPattern=".*" deny="false" />
<aaaRuleGroup name="dpaas">
<aaaRule loginIdPattern=".*" orgIdPattern=".*"
deny="false" />
I want to retrieve orgIdPattern and loginIdPattern parameter value based on... (2 Replies)
Hi All,
I have the following code in one of my xml file:
<com:parameter>
<com:name>secretKey</com:name>
<com:value>31XA874821172E89B00B1C</com:value>
</com:parameter>
<com:parameter>
<com:name>tryDisinfect</com:name>
<com:value>false</com:value>
</com:parameter>
<com:parameter>... (4 Replies)