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 » Help with accessing XML Elements based on their attributes

Post new topic  Reply to topic
 Help with accessing XML Elements based on their attributes « View previous topic :: View next topic » 
Author Message
sorn73
PostPosted: Fri Oct 07, 2005 4:34 am    Post subject: Help with accessing XML Elements based on their attributes Reply with quote

Novice

Joined: 24 Mar 2004
Posts: 24
Location: Sweden

Hello fellow WMBers!

I have a customer that recieves messages in a standardized XML format. The standard is apparently developed cross-organizations, so I have no control over the structure.

The people who designed the XML format are very fond of using attributes to tag data, so I have something like:

Code:
<A>
<NAME type="first">John</NAME>
<NAME type="last">Doe</NAME>
</A>


This bugs me, as I can't reference an element using a unique path. I would like to do

Code:
SET SomeVar = FIELDVALUE( A.NAME.(XML.Attr)type='last' );


but that's just plain stupid. I also tried something like

Code:
SET SomeVar[] = (SELECT I.NAME FROM A.*[] AS I WHERE I.NAME.(XML.Attr)type = 'last' ) ;


but I can't get the syntax right. I have resorted to looping over the elements, checking the attribute values and setting a lot of pointers that I can use later, a solution that I find horrible.

Has anyone else seen this scenarion and solved in a more elegant way?
Back to top
View user's profile Send private message
JT
PostPosted: Fri Oct 07, 2005 5:31 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Try this:
Code:
SET SomeVar = THE(SELECT ITEM I FROM A.NAME[] AS I WHERE I.(XML.Attr)type = 'last' )
Back to top
View user's profile Send private message
sorn73
PostPosted: Sun Oct 09, 2005 11:36 am    Post subject: Reply with quote

Novice

Joined: 24 Mar 2004
Posts: 24
Location: Sweden

Yay! This worked like a charm... With two minor glitches. First of all (XML.Attr) didn't work for some reason, I had to write (XML.Attribute)... Go figure. Also, I only wanted the fieldvalue and not the attributes, but wrapping the select in FIELDVALUE() didn't work, so I bounced via a dummy character value.
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 » Help with accessing XML Elements based on their attributes
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.