|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Access XML tag with the same prefix |
« View previous topic :: View next topic » |
Author |
Message
|
KIT_INC |
Posted: Fri Jun 04, 2010 9:09 am Post subject: Access XML tag with the same prefix |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I have an Input XML which contains a variable number of tags all prefixed with AA , the xx, yy ww can be anything.
<TEST_MSG>
<DATA>
<AA_xx>nn</<AA_xx>
<AA_yy>qq</AA_yy>
:
<AA_ww>rr</AA_ww>
<BB/>
<CC/>
<DD/>
</DATA>
</TEST_MSG>
I need to access these AA* fileds to create the output message. IF I do a cardinality under TEST_MSG.DATA, I am counting the BB and the CCs also. One way I can think of is to get the total number of elements under DATA and get the fieldnames one by one and compare if it has the AA prefix. This seems too tedious because there can be hundreds of elements under DATA. Any suggestion on how I can get the count and the fieldnames names ? |
|
Back to top |
|
 |
fatherjack |
Posted: Fri Jun 04, 2010 9:17 am Post subject: Re: Access XML tag with the same prefix |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
KIT_INC wrote: |
One way I can think of is to get the total number of elements under DATA and get the fieldnames one by one and compare if it has the AA prefix. This seems too tedious because there can be hundreds of elements under DATA. |
But if you need the contents of those elements to construct your output message don't you have to access them one by one anyway? _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
KIT_INC |
Posted: Fri Jun 04, 2010 10:26 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
But all I need is the AA*, not the BBs and CCs which may may hundreds. |
|
Back to top |
|
 |
mgk |
Posted: Fri Jun 04, 2010 12:21 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
You go not need to count all the elements. You can either do the transform directly into the output message using a SELECT, or use a REFERENCE variable and move it over each element, testing its FIELDNAME and STARTSWITH('AA') until Lthe ASTMOVE returns FALSE...
Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|