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 » Extracting values from the xml

Post new topic  Reply to topic
 Extracting values from the xml « View previous topic :: View next topic » 
Author Message
geethgubi
PostPosted: Sat Jan 10, 2009 11:34 am    Post subject: Extracting values from the xml Reply with quote

Apprentice

Joined: 18 Dec 2008
Posts: 44

I have an xml like the below. I have 2 message flows. I need some of the values of n:NameValuePair like I just need only the status and the last name in the 1st message flow and FirstName, lastname and status in my second messageflow. I am extracting these values by looping (using while loop) through all the n:NameValuePair in n:NameValuePairs and checking the value of <n:Name>Status</n:Name>
and if it is my required element I get the value of <n:Value></n:Value> element. Since its performance intensive to loop through all these n:NameValuePair just to get one or 2 values, I used like this n:NameValuePairs.n:NameValuePair[2].n:Value wherever I need whatever. But as thats not the good way of coding. I would like to know is there any generic way of extracting the value of any of the any element in esql code? As I am the newbie with Message broker. Can someone pls help me out with this query? Thanks.

<n:NameValuePairs>
<n:NameValuePair>
<n:Name>Status</n:Name>
<n:Value></n:Value>
</n:NameValuePair>
<n:NameValuePair>
<n:Name>FirstName</n:Name>
<n:Value></n:Value>
</n:NameValuePair>
<n:NameValuePair>
<n:Name>MiddleName</n:Name>
<n:Value></n:Value>
</n:NameValuePair>
<n:NameValuePair>
<n:Name>LastName</n:Name>
<n:Value></n:Value>
</n:NameValuePair>
</n:NameValuePairs>
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sat Jan 10, 2009 1:02 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There's no reason you should have posted this under News/Updates.

There's no reason that looping over a repeating structure in order to find specific values is "performance intensive", nor any particular reason why it's "bad coding". In order to sort items, you always have to look at all of the items at least once - where "performance intensive" or "bad coding" comes in place is in *how* you look at all the items in the list. In order to find the Name items that you are looking for, you are going to have to look at all of the Name items that occur "before" the items you are looking for.

And you can't say any piece of code is performance intensive without knowing what "good" performance" is and what "bad performance" is.

There's no reason to design an XML message like you have demonstrated. Someone who did design that should be forced to answer this question for you, and then justify their design based on the complexity of the solution you are forced to.

Being new to WMB doesn't change how you solve problems with it, nor should it.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Sat Jan 10, 2009 1:46 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Moved to WMB Forum
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
kimbert
PostPosted: Sat Jan 10, 2009 1:58 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I agree with mqjeff re: the design of the incoming XML document. But as you probably cannot change that...
Quote:
I am extracting these values by looping (using while loop) through all the n:NameValuePair in n:NameValuePairs and checking the value of <n:Name>Status</n:Name>
and if it is my required element I get the value of <n:Value></n:Value> element.
I wonder whether the ESQL SELECT function would help: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ak05620_.htm
and
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67150_.htm

I am not claiming that it will be faster, but you may end up with less ESQL to maintain.
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 » Extracting values from the xml
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.