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 » Parsing a Marked up Xml string inside an xml document

Post new topic  Reply to topic
 Parsing a Marked up Xml string inside an xml document « View previous topic :: View next topic » 
Author Message
MasterMind
PostPosted: Sun May 15, 2011 1:22 pm    Post subject: Parsing a Marked up Xml string inside an xml document Reply with quote

Newbie

Joined: 09 Nov 2010
Posts: 9

Hi ,

I am looking for possible options to parse the following content


<NS1:Root xmlns:NS1="http://abc.com">
<NS1:E1>
<NS1:e2>xxx</NS1:e2>
<NS1:e3>xxx</NS1:e3>

<NS1:Root1 >
&lt;testdata xmlns=&quot;http://www.bcd.com&quot; xmlns:prdate=&quot;http://www.abc.com&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.abc.com/payload/testdata.xsd &gt;&lt;item&gt;1234&lt;/item&gt;&lt;component_type&gt;N&lt;/component_type&gt;&lt;value&gt;5350&lt;/value&gt;&lt;/testdata&gt;
</NS1:Root1 >
</NS1:E1>
</NS1:Root >

As you see thee message has a marked up xml included under root1, i am able to fetch it into a environment variable/output root , but i am not able to parse the elements under root (Environment.variable.Data.XMLNSC.testdata.item)
Its not able to understand the xpath.

I got the content of Root1 from input xml into a string and than using Create , parsed it through XMLNSC parser.

its not allowing me to parse it directly using xpath, is it the issue with the namespace declerations which are redundent, can we remove it in any way. I dont want to use the substring option.

And there is no scope for changing the input xml (its being sent from an existing application). please suggest.

Regards,
MM
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sun May 15, 2011 8:00 pm    Post subject: Reply with quote

Grand High Poobah

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

Quote:
I got the content of Root1 from input xml into a string and than using Create , parsed it through XMLNSC parser.

its not allowing me to parse it directly using xpath, is it the issue with the namespace declerations which are redundent, can we remove it in any way. I dont want to use the substring option.

And there is no scope for changing the input xml (its being sent from an existing application). please suggest.


Working as designed. Why would you want to use xpath against something that is not yet in the message / environment tree?

Seems you solved the problem and got the embedded XML into a tree using create parse which is the right way to handle this...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Mon May 16, 2011 2:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

As fj says, until you have instructed Broker to treat that string as an XML document and parse it, it is still just a string which is a single value, and thus you can't access pieces of it as if they were part of a logical message tree.

Whoever is producing this XML document is probably doing the wrong thing. They probably do not intend to be producing this data as a value and are somehow expecting that it will be parsed as XML data.

However, whatever is being done to create it is being done the wrong way and so it comes out this way.
Back to top
View user's profile Send private message
MasterMind
PostPosted: Mon May 16, 2011 10:08 am    Post subject: Reply with quote

Newbie

Joined: 09 Nov 2010
Posts: 9

It was fairly simple, i was able to parse the xml as below


DECLARE xmlString CHARACTER InputRoot.XMLNSC.ns1:Root.ns1:E1.ns1:Root1;
CREATE LASTCHILD OF Environment.Variable.Data DOMAIN ('XMLNSC') PARSE (xmlString CCSID 1208);

the env tree can now be parsed.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon May 16, 2011 10:27 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

MasterMind wrote:
It was fairly simple, i was able to parse the xml as below


DECLARE xmlString CHARACTER InputRoot.XMLNSC.ns1:Root.ns1:E1.ns1:Root1;
CREATE LASTCHILD OF Environment.Variable.Data DOMAIN ('XMLNSC') PARSE (xmlString CCSID 1208);

the env tree can now be parsed.


Yes, this is the right way to parse this data. But again, you probably should review whether this data is expected to be a single string like it is...

And you should also be aware that passing this kind of xml document within another xml document can lead to difficulties if care isn't taken.
Back to top
View user's profile Send private message
MasterMind
PostPosted: Mon May 16, 2011 10:36 am    Post subject: Reply with quote

Newbie

Joined: 09 Nov 2010
Posts: 9

agreed, but with a little bit of care we can parse the xml easily.
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 » Parsing a Marked up Xml string inside an xml document
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.