|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Convert XML string (with attributes) to XML |
« View previous topic :: View next topic » |
Author |
Message
|
jpm |
Posted: Tue Jul 01, 2003 3:40 am Post subject: Convert XML string (with attributes) to XML |
|
|
 Newbie
Joined: 23 Apr 2003 Posts: 6
|
Hi,
I have a java plugin node that retrieves an XML string which contains attributes. I assign this XML string to an environment variable, so in MQSI I have something like
Code: |
Environment.Results = '<Tag><Tag1 attr1="value1"><Tag2 attr2="value2"></Tag>' |
How do I parse the XML string to build an XML tree structure?
I have tried
Code: |
CREATE NEXTSIBLING OF Environment.Results DOMAIN('XML') PARSE(Environment.Results,273,819); |
In a trace, this produces something like
Code: |
(0x3000000)Results = '<Tag><Tag1 attr1="value1"><Tag2 attr2="value2"></Tag>
(0x1000010)XML = (
(0x1000000)Results = (
(0x1000000)Tag = (
(0x1000000)Tag1 = (
(0x3000000)attr1 = 'value1'
...etc |
but how I do reference the results? Environment.XML.Results returns null. Yet, the values are in the trace.
Many thanks,
John |
|
Back to top |
|
 |
Craig B |
Posted: Tue Jul 01, 2003 3:55 am Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
Since your data is not in a message tree you have to access the fields themselves to get at your data. So for your example, one way of accessing the data would be by using a field reference such as :
Environment.XML.Results,Tag.Tag1.(XML.Attribute) attr1
to get at the value 'value 1'.
When you referenced then Environment.XML.Results, then depending on what operation you are performing you will either get the subtree it represents or just the value of that single field. If you got a NULL value back the it is likely your operation (such as a CAST) on Environment.XML.Results could only operate on single values. And in this case this field does not have a value itself .... it just has a subtree. _________________ Regards
Craig |
|
Back to top |
|
 |
jpm |
Posted: Tue Jul 01, 2003 5:52 am Post subject: |
|
|
 Newbie
Joined: 23 Apr 2003 Posts: 6
|
Thanks for the response.
Is it possible to parse the XML string so that it constructs a message tree?
I am trying to get the XML string in a format or tree structure, that will allow me to use ESQL functions on it. Such as the CARDINALITY() function. |
|
Back to top |
|
 |
Craig B |
Posted: Tue Jul 01, 2003 8:30 am Post subject: |
|
|
Partisan
Joined: 18 Jun 2003 Posts: 316 Location: UK
|
In your previous update you showed that your trace looked like the following :
Code: |
(0x1000010)XML = (
(0x1000000)Results = (
(0x1000000)Tag = (
(0x1000000)Tag1 = (
(0x3000000)attr1 = 'value1'
|
That is a parsed XML message tree. Isnt this what you require? _________________ Regards
Craig |
|
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
|
|
|
|