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 » Accessing XML element in Java compute node

Post new topic  Reply to topic
 Accessing XML element in Java compute node « View previous topic :: View next topic » 
Author Message
geethgubi
PostPosted: Thu Jan 08, 2009 12:32 pm    Post subject: Accessing XML element in Java compute node Reply with quote

Apprentice

Joined: 18 Dec 2008
Posts: 44

I have the following xml (sample) with namespaces

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:m="...." xmlns:n="....">
<env:Header>
.... </env:Header>
<env:Body>
<tns:Cust xmlns:tns="...." xsi:schemaLocation=".....">
<tns:a>abcd/tns:a>
<tns:b>123456</tns:b>
<tns:c>xyz</tns:c>
<tns:d>pqr</tns:d>
</tns:Cust>
</env:Body>
</env:Envelope>

I would like to access the value of the element env:Envelope.env:Body.tns:Cust.tns:a in Java compute node. Can somebody pls help out with the solution to this asap. Thanks
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Jan 08, 2009 3:20 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

What have you tried, and what happened when you tried it?
Back to top
View user's profile Send private message
geethgubi
PostPosted: Thu Jan 08, 2009 3:33 pm    Post subject: Reply with quote

Apprentice

Joined: 18 Dec 2008
Posts: 44

I have tried

MbElement msgTxtElement = body.getFirstElementByPath("/XML/env:Envelope/env:Body/tns:Cust/tns:a");

not the exact string as above. I modified tns:Cust/tns:a as per my actual xml. But I couldnt test this at all as I am getting some error with deployment. But no one is here to tell me whether it is correct or not.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Jan 09, 2009 1:52 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Why are you using the deprecated XML domain? It does not support namespaces.
Please read this infocenter topic: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ad70530_.htm
...and then change your flow to use XMLNSC.
Back to top
View user's profile Send private message
geethgubi
PostPosted: Fri Jan 09, 2009 5:05 am    Post subject: Reply with quote

Apprentice

Joined: 18 Dec 2008
Posts: 44

I know that XML is the deprecated domain and we should use XMLNS. But I need the sample code to achieve it. Pls let me know if you find any. Thanks.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Jan 09, 2009 5:13 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

No, you should not use XMLNS. You should use XMLNSC ( assuming that you are on v6.0 or later ).

The XML domain does not support namespaces.
Your document has namespaces.
So you will never get it working with the XML domain.

There is no need for sample code - this is a very simple task. Your next step is to switch to XMLNSC and try again.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 09, 2009 5:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The code you showed will work for accessing a message element regardless of what parser the message is described by. Although you must adjust your path string to include the name of the parser that is being used.

And again, the parser that should be used is XMLNSC, not XML, and not XMLNS.

And there's *lots* of sample code in various posts in this forum. Have you looked for it?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing XML element in Java compute node
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.