By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,850 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,850 IT Pros & Developers. It's quick & easy.

Extracting text within a specified xml tag

P: 2
Hi

I am new in xml handling in perl
Can anyone help me in getting the text portion within a particular tag in an xml document .

Say for eg i have a xml doc

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xmsMessage><header><network>SWIFT</network><msgDirection>intoMS</msgDirection><extMsgName>MT198</extMsgName><sendSession/><sendSequence/><nakError/><mervaMessage><code>DWS765I</code><message>Auth OK, key DIGEST, MSITITM0 BITAITR0 record</message></mervaMessage></header><senderMessageReference>BI0800700001105</senderMessageReference><subMsgName>155</subMsgName><noTag>77E</noTag><relatedMessageReference>1000170</relatedMessageReference><noTag>913:080107133235</noTag><noTag>901:A080107ITDE00001</noTag><noTag>990:0</noTag></xmsMessage> 
  3.  
I want to extract all the text that are within the tag <noTag>DATA1</noTag>.
noTag can be multiple times in the message and i want values for all the no tags.


Thanks
Jan 8 '08 #1
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
Hi

I am new in xml handling in perl
Can anyone help me in getting the text portion within a particular tag in an xml document .

Say for eg i have a xml doc

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <xmsMessage><header><network>SWIFT</network><msgDirection>intoMS</msgDirection><extMsgName>MT198</extMsgName><sendSession/><sendSequence/><nakError/><mervaMessage><code>DWS765I</code><message>Auth OK, key DIGEST, MSITITM0 BITAITR0 record</message></mervaMessage></header><senderMessageReference>BI0800700001105</senderMessageReference><subMsgName>155</subMsgName><noTag>77E</noTag><relatedMessageReference>1000170</relatedMessageReference><noTag>913:080107133235</noTag><noTag>901:A080107ITDE00001</noTag><noTag>990:0</noTag></xmsMessage> 
  3.  
I want to extract all the text that are within the tag <noTag>DATA1</noTag>.
noTag can be multiple times in the message and i want values for all the no tags.


Thanks
Can you please show us the code you have tried thus far? That way we can work with you to help you do what you want to.

Regards,

Jeff
Jan 8 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.