Author |
Message
|
premji |
Posted: Tue May 15, 2018 11:06 am Post subject: Not able to retrieve child tag from XML |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi,
I am facing problem while retrieving data tag from below XML using ESQL, can you please help me if you get a chance?
Source XML looks like :
Code: |
<tst:getRes xmlns:tst="http://wb.samples.com"><tst::getRrn><?xml version="1.0" encoding="UTF-8"?>
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<ship></ship></data><tst::getRrn></tst:getRes> |
Thanks in advance |
|
Back to top |
|
 |
Vitor |
Posted: Tue May 15, 2018 11:16 am Post subject: Re: Not able to retrieve child tag from XML |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
premji wrote: |
I am facing problem while retrieving data tag from below XML using ESQL, can you please help me if you get a chance? |
Perhaps if you shared a few extra details like:
- what your ESQL looks like
- what result you expect
- what result you're getting
- what you're tried already to resolve it
- an extract of a user trace of the ESQL in question executing
"I am facing problem" conveys nothing.
I am facing problem with desk - can you help me with that, based on that statement? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
premji |
Posted: Tue May 15, 2018 11:22 am Post subject: Not able to retrieve child from XML |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Hi Vitor,
I wrote below ESQL to retrieve data element but payload returning null value for that.
DECLARE tst NAMESPACE 'http://wb.samples.com';
DECLARE PayLoad BLOB;
SET PayLoad= ASBITSTREAM(InputRoot.XMLNSC."{tst:getRes}"."{tst:getRrn}" ENCODING InputRoot.MQMD.Encoding CCSID InputRoot.Properties.CodedCharSetId);
And expected output would be:
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<shipment></shipment>
</data>
Last edited by premji on Tue May 15, 2018 11:39 am; edited 2 times in total |
|
Back to top |
|
 |
Vitor |
Posted: Tue May 15, 2018 11:35 am Post subject: Re: Not able to retrieve child from XML |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
premji wrote: |
I wrote below ESQL to retrieve data element but payload returning null value for that. |
Are they charging you by the linebreak?
premji wrote: |
DECLARE tst NAMESPACE 'http://wb.samples.com |
I'm going to assume there's a closing quote and a semicolon on the running version.
premji wrote: |
DECLARE PayLoad, BLOB;
|
and no comma between PayLoad and the type definition
premji wrote: |
SET PayLoad= ASBITSTREAM(InputRoot.XMLNSC."{tst:getRes}"."{tst:getRrn}" ENCODING InputRoot.MQMD.Encoding CCSID InputRoot.Properties.CodedCharSetId);
And expected output would be:
<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<shipment></shipment>
</data> |
Ok, why the double quotes around the 2 child tags?
How about you declare a reference to the data tag and pass that to ASBITSTREAM? Squander a line break.
This will also show more clearly in the user trace I asked about (HINT!) if the problem is finding the data tag or serializing the data tag. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
premji |
Posted: Tue May 15, 2018 11:52 am Post subject: Not able to retrieve child from XML |
|
|
Acolyte
Joined: 01 Jul 2013 Posts: 64
|
Thanks Vitor, I have tried with reference and it's working as expected. |
|
Back to top |
|
 |
Vitor |
Posted: Tue May 15, 2018 12:14 pm Post subject: Re: Not able to retrieve child from XML |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
premji wrote: |
Thanks Vitor, I have tried with reference and it's working as expected. |
So you don't pass it that weird evaluated location but an actual point in the tree to start serializing from and it works? Go figure.....
But you have the result you want and all is well.
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue May 15, 2018 2:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What the OP had was and embedded XML document in the XML.
The data shown lists an XML declaration plus the data specified by the user.
So the first thing was to retrieve the tagdata containing the XML. (Thanks Vitor)
The second / third moves could have been to cast that data to a BLOB (utf-8 ) and then parse it again with the XMLNSC parser...
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|