Search in xml tags


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Search in xml tags
# 1  
Old 11-10-2011
Search in xml tags

I have a xml file like below. I want to search in <msg>, if found corresponding tag path needs to fetch.

for eg: for the message 'RM1659 Boeing Exception Management' it should return /trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Smartview.zip
For message it can have many paths.

Please give me a correct commands to find it.

Code:
<?xml version="1.0"?>
<log>
<logentry
   revision="428">
<date>2011-09-23T07:25:28.059356Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Transfer_SMRTVW_DBF.zip</path>
</paths>
<msg>Redmine : 613 FTP details moved to parameters table </msg>
</logentry>
<logentry
   revision="373">
<date>2011-08-26T12:36:11.583506Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Smartview.zip</path>
</paths>
<msg>RM1659 Boeing Exception Management</msg>
</logentry>
<logentry
   revision="372">
<date>2011-08-26T12:32:51.179995Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Smartview.zip</path>
</paths>
<msg>RM1659 Boeing Exception Management</msg>
</logentry>
<logentry
   revision="175">
<date>2011-06-21T10:44:43.849019Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Transfer_SMRTVW_DBF.zip</path>
</paths>
<msg>Redmine Issue 1233:
* Modified the JET for tSCPPut_main.javajet to re-raise the Java exception on SCP Put failure.
* Added a tDie step to abort if SCP file rename fails.  Checking for status "File rename OK" to detect success.</msg>
</logentry>
<logentry
   revision="52">
<date>2011-05-17T11:41:14.775777Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Smartview.zip</path>
</paths>
<msg>Added logging statements for file paths.</msg>
</logentry>
<logentry
   revision="47">
<date>2011-05-16T07:56:47.727376Z</date>
<paths>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Smartview.zip</path>
<path
   kind="file"
   action="M">/trunk/talend/source/SITA_SP7/Job_Designs/DeferredOutputs/SmartViewFiles/DO_Transfer_SMRTVW_DBF.zip</path>
</paths>
<msg>Fixing issues after the initial implementation of changes corresponding to
Redmine Issue 801 - Modified the file path in the Fetch File Names Component in DO_transfer_SMRTVW_DBF and DO_Smartview jobs.</msg>
</logentry>


Last edited by fpmurphy; 11-10-2011 at 11:12 AM.. Reason: code tags please
# 2  
Old 11-10-2011
# 3  
Old 11-23-2011
By commands do you mean shell script or Perl script? I can recommend to do it in the latter, but if takes on a more structural form, you may want to look into XML databases such as sedna (Sedna XML Database).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pull multiple XML tags from the same XML file in Shell.?

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)
Discussion started by: hungryd
9 Replies

2. Shell Programming and Scripting

Search and replace the string with new word using xml tags

Hi All i need to replace the url1 inside <remote> tag in below xml in first instance and in the second instance with url2. any help appreciated <locations> <hudson.scm.SubversionSCM_-ModuleLocation> <remote>https://svn2015.com/svn/repos/internalshard</remote> ... (4 Replies)
Discussion started by: madankumar.t@hp
4 Replies

3. Shell Programming and Scripting

How to add Xml tags to an existing xml using shell or awk?

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)
Discussion started by: Nevergivup
2 Replies

4. Shell Programming and Scripting

Compare two xml files while ignoring some xml tags

I've got two different files and want to compare them. File 1 : <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record id="38,557"><columns><column><name>orge... (2 Replies)
Discussion started by: Shaishav Shah
2 Replies

5. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

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)
Discussion started by: Shaishav Shah
1 Replies

6. 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

7. Shell Programming and Scripting

Print a pattern between the xml tags based on a search pattern

Hi all, I am trying to extract the values ( text between the xml tags) based on the Order Number. here is the sample input <?xml version="1.0" encoding="UTF-8"?> <NJCustomer> <Header> <MessageIdentifier>Y504173382</MessageIdentifier> ... (13 Replies)
Discussion started by: oky
13 Replies

8. Shell Programming and Scripting

how to search xml tags using unix shell

Hi All, Good day Here is my data: <Journal> <JournalCode>2</JournalCode> <JournalType>L</JournalType> <JournalEntry>SG</JournalEntry> <JournalAmount>-0.05</JournalAmount> </Journal> Problem: 1) I need to query the above tags in xml. Which is from the header <Journal>... (4 Replies)
Discussion started by: lutinoman
4 Replies

9. Shell Programming and Scripting

how to search a value from a xml

I have a file which has following content. <drdata_export> <drdata> <tags> <timestamp>1231420399:617026000</timestamp> <from_ip_address>67.178.40.168</from_ip_address> <to_ip_address>76.96.6.6</to_ip_address> ... (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

10. UNIX for Dummies Questions & Answers

Search for xml tags in a file

Hi, I need to search for a pattern like : <A:UserAttr Name="ACTIVITY_ID"> <A:Value>1111120</A:Value> </A:UserAttr> Let us the there is a dir /tmp that contains 5 xml file. each of them multiple above tags in the file. If found all the three line would be... (2 Replies)
Discussion started by: tictactoe
2 Replies
Login or Register to Ask a Question