ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportESQL: Accesing XML fields

Post new topicReply to topic
ESQL: Accesing XML fields View previous topic :: View next topic
Author Message
chaitanyauk
PostPosted: Sun Feb 17, 2019 4:33 am Post subject: ESQL: Accesing XML fields Reply with quote

Apprentice

Joined: 16 Apr 2017
Posts: 29

Hello Experts,

I trying to access some field value in XML message through ESQL code(using XMLNSC parser), but not able to access the value:

below is my Sample XML:

Code:
<ZXML xsi:schemaLocation="http://www.abc.com/zxml trans.xsd" xmlns="http://www.abc.com/zxml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <Header>
      <Data>
         <Key>
            <ID>12345</ID>
         </Key>       
      </Data>
   </Header>
</ZXML>


below is my ESQL code, in none of the way was I able to fetch the data:

Code:
SET val1 = InputRoot.XMLNSC.ZXML.Header.Data.Key.ID;
   SET val2 = InputRoot.XMLNSC.*.Header.Data.Key.ID;
   
   SET val3 = InputRoot.XMLNSC.(XMLNSC.Element)Header.Data.Key.ID;
   SET val4 = InputRoot.XMLNSC.*.*.*.*.Header.Data.Key.ID;


Also tried removing the namespace, as given here:

https://developer.ibm.com/answers/questions/210953/how-to-remove-or-delete-namespaces-from-xmlnsc-dom/

Code:
SET OutputRoot.XMLNSC.*:ZXML.(XMLNSC.NamespaceDecl)* = NULL;
      SET OutputRoot.XMLNSC.*:ZXML NAMESPACE = '';
         
      SET OutputRoot.XMLNSC.*:ZXML.(XMLNSC.Attribute)xsi = NULL;
      SET OutputRoot.XMLNSC.*:ZXML.(XMLNSC.Attribute)schemaLocation = NULL;


I was able to remove the namespace: xmlns="http://www.abc.com/zxml", whereas other namespaces remained as it is.

Tried to fetch fieldvalue of the first element, got null;

Code:
SET fv =  FIELDNAME(InputRoot.XMLNSC.ZXML); --gives null



Is there any thing wrong with namespace?

Any help in this regard would be great.

Back to top
View user's profile Send private message
timber
PostPosted: Mon Feb 18, 2019 1:42 am Post subject: Reply with quote

Guardian

Joined: 25 Aug 2015
Posts: 961

Please add a Trace node in your message flow. Put it immediately after the input node, and set the Pattern to ${Root}. Post the output in this thread, and I can then explain what is happening.
Back to top
View user's profile Send private message
chaitanyauk
PostPosted: Mon Feb 18, 2019 4:21 am Post subject: Reply with quote

Apprentice

Joined: 16 Apr 2017
Posts: 29

Solved!
Was able to fetch value with below code:

Quote:
SET val1 = InputRoot.XMLNSC.*:ZXML.*:Header.*:Data.*:Key.*:ID;


XML elements inherit the parent element namespaces by default unless it is specified explicitly.

Thank you!
Back to top
View user's profile Send private message
timber
PostPosted: Mon Feb 18, 2019 5:07 am Post subject: Reply with quote

Guardian

Joined: 25 Aug 2015
Posts: 961

Glad you got it working, but this statement is not accurate:
Quote:
XML elements inherit the parent element namespaces by default unless it is specified explicitly
If you believe that, you will end up very confused next time you deal with an XML message. I suggest that you check out an XML tutorial - the rules are not difficult to understand.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportESQL: Accesing XML fields
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.