|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
copying XML elements and associated attributes |
« View previous topic :: View next topic » |
Author |
Message
|
JohnMetcalfe |
Posted: Mon Feb 21, 2005 8:24 am Post subject: copying XML elements and associated attributes |
|
|
 Apprentice
Joined: 02 Apr 2004 Posts: 40 Location: Edinburgh, Scotland
|
Does anyone know how to extract an element and associated attributes, but not pull over all the child elements as well
e.g given an input message such as this below:
<Message type="ILCMD" category="AuditMsgResend" >
<Cmd>
<Parameter name=’AUDIT_ID’>2345</ Parameter >
<Parameter name=’TARGETQ’>SLI.???????? </ Parameter >
/Cmd >
</Message>
I need to pull over the Message element and attributes to the Output, but not the child element and attributes.
I want a generic way of doing this, as the attribute set can vary across message types, so I don't want to have to hardcode the attribute names I'm looking for.
The output I'm looking to create is:
<Message type="ILCMD" category="AuditMsgResend">
.. other stuff in here....
</Message>
Thanks for any pearls of wisdom in advance! |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Feb 21, 2005 8:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you only copy the message headers, and then write ESQL to copy the specific fields you want, and not copy the tree, then it will only copy what it tells you to.
If you need to refer to a field without using it's name, then you need to use an anonymous field reference. There is a section in the documentation on using anonymous field references in ESQL. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
JohnMetcalfe |
Posted: Mon Feb 28, 2005 9:09 am Post subject: |
|
|
 Apprentice
Joined: 02 Apr 2004 Posts: 40 Location: Edinburgh, Scotland
|
Thanks for your input Jeff,
I've finally solved the problem with the following code:
Code: |
declare c integer;
set c = cardinality (InputRoot.XML.a.(XML.attr)*[]);
declare i integer;
set i = 1;
while i <= c do
set OutputRoot.XML.a.(XML.attr)[i] = InputRoot.XML.a.(XML.attr)[i];
set i = i + 1;
end while; |
This copies an element and all its associated attributes, without knowing the names or number of attiributes beforehand, and it does NOT copy any child elements |
|
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
|
|
|
|