Author |
Message
|
dsmq |
Posted: Thu Jul 17, 2003 10:40 am Post subject: How to find the XML tag |
|
|
Acolyte
Joined: 20 Jun 2002 Posts: 59
|
Hi all
How do i find the specific XML tag exists in my incoming XML or not
Here is my Sample xml Msg
<SampleMsg>
<Sample>
<name>hello</name>
<rno>1</rno>
</Sample>
</SampleMsg>
i want to find the <name> tag exits or not . Can body can give me the code to loop through the all xml tags and look for <name> tag
Thanks in advance |
|
Back to top |
|
 |
kirani |
Posted: Thu Jul 17, 2003 10:43 am Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Try this ..
Code: |
IF ( InputRoot.XML.SampleMsg.Sample IS NOT NULL) THEN
-- the Tag exist
ELSE
-- The TAG doesn't exist or contains NULL Value
END IF;
|
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
dsmq |
Posted: Thu Jul 17, 2003 11:10 am Post subject: How to find the XML tag |
|
|
Acolyte
Joined: 20 Jun 2002 Posts: 59
|
Hi Kiran
Thanks for u r reply
if i don't know the position of XML tag, then how do we check.
<SampleMsg>
<Sample>
<name>hello</name>
<rno>1</rno>
</Sample>
</SampleParser>
in this XML i may get <name> tag as child of <Sample> or sometimes i will get as child of <SampleMsg>
like
<SampleMsg>
<name>hello</name>
<Sample>
<rno>1</rno>
</Sample>
</SampleParser>
How do i write a generic code to see the FIELD NAME of particular tag is <name>
Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 17, 2003 11:34 am Post subject: Re: How to find the XML tag |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
dsmq wrote: |
if i don't know the position of XML tag, then how do we check.
|
You should be able to use a Select statement against the message tree to find this tag. Read the latest version of the ESQL manual for more information. |
|
Back to top |
|
 |
titus |
Posted: Fri Jul 18, 2003 6:01 am Post subject: |
|
|
Novice
Joined: 14 Oct 2002 Posts: 23
|
Another solution is read message as blob and cast into char . Then find the position of tag in the message using POSITION function. |
|
Back to top |
|
 |
|