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 Index » WebSphere Message Broker (ACE) Support » XML PARENT TAG

Post new topic  Reply to topic
 XML PARENT TAG « View previous topic :: View next topic » 
Author Message
mahek
PostPosted: Thu Nov 30, 2006 11:52 am    Post subject: XML PARENT TAG Reply with quote

Voyager

Joined: 10 Sep 2004
Posts: 87

Hi all,
How to find the parent tag name in the xml document using esql.

for example

<A>
<B>B</B>
<C>C</C>
</A>

I want to get the name of the parent tag as A
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Thu Nov 30, 2006 11:59 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ak05540_.htm
_________________
Joseph
Administrator - IBM WebSphere MQ (WMQ) V6.0, IBM WebSphere Message Broker (WMB) V6.1 & V6.0
Solution Designer - WMQ V6.0
Solution Developer - WMB V6.1 & V6.0, WMQ V5.3
Back to top
View user's profile Send private message AIM Address
mahek
PostPosted: Thu Nov 30, 2006 12:11 pm    Post subject: Reply with quote

Voyager

Joined: 10 Sep 2004
Posts: 87

Hi Joseph,

I am getting XML as the result instead of getting the result as A while using the code mentioned in the document
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Thu Nov 30, 2006 12:28 pm    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

So you tried,

FIELDNAME(InputRoot.XML.*[1])

To find out what the name is of the first (and only) child of the XML document?
_________________
Joseph
Administrator - IBM WebSphere MQ (WMQ) V6.0, IBM WebSphere Message Broker (WMB) V6.1 & V6.0
Solution Designer - WMQ V6.0
Solution Developer - WMB V6.1 & V6.0, WMQ V5.3
Back to top
View user's profile Send private message AIM Address
mahek
PostPosted: Thu Nov 30, 2006 12:58 pm    Post subject: same problem Reply with quote

Voyager

Joined: 10 Sep 2004
Posts: 87

it is still giving me the value as XML
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Nov 30, 2006 12:59 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
I am getting XML as the result instead of getting the result as A while using the code mentioned in the document
I suspect that your input document has an xml declaration before the root tag. You need to qualify that path with the type of element that you are seeking.
Something like
Code:
FIELDNAME(InputRoot.XML.(XML.Element)*[1])

( not tested )
Back to top
View user's profile Send private message
mahek
PostPosted: Thu Nov 30, 2006 1:06 pm    Post subject: Reply with quote

Voyager

Joined: 10 Sep 2004
Posts: 87

Hi kimbert, joseph ,
Thanks a lot it works now when i use
FIELDNAME(InputRoot.XML.(XML.Element)*[1]).

Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 30, 2006 1:22 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

But of course, you really are using InputRoot.XMLNS or InputRoot.XMLNSC because of course you aren't using the deprecated XML parser and of course you are using version 5.x or 6.x and not the unsupported 2.1.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Thu Nov 30, 2006 2:12 pm    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

Observe the behaviour in this code snipit:

Code:

DECLARE iRootTag INTEGER CARDINALITY(InputRoot.XMLNSC.*[]);
DECLARE szRootTag CHARACTER;
FOR pXML AS InputRoot.XMLNSC.*[] DO
   SET szRootTag = FIELDNAME(pXML);
END FOR;


You will see that you get two tags. The XML declaration and the one you want. I guess you could always just look at the second element.
_________________
Joseph
Administrator - IBM WebSphere MQ (WMQ) V6.0, IBM WebSphere Message Broker (WMB) V6.1 & V6.0
Solution Designer - WMQ V6.0
Solution Developer - WMB V6.1 & V6.0, WMQ V5.3
Back to top
View user's profile Send private message AIM Address
fjb_saper
PostPosted: Thu Nov 30, 2006 3:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

JosephGramig wrote:
Observe the behaviour in this code snipit:

Code:

DECLARE iRootTag INTEGER CARDINALITY(InputRoot.XMLNSC.*[]);
DECLARE szRootTag CHARACTER;
FOR pXML AS InputRoot.XMLNSC.*[] DO
   SET szRootTag = FIELDNAME(pXML);
END FOR;


You will see that you get two tags. The XML declaration and the one you want. I guess you could always just look at the second element.

Not reliable. Go through the children first level and check the type against the element type. That should always give you the tag on a well formed XML doc.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » XML PARENT TAG
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.