Author |
Message
|
Lillian |
Posted: Thu Dec 28, 2006 5:30 am Post subject: accessing xml tag |
|
|
Centurion
Joined: 15 Apr 2002 Posts: 102
|
Below is a trace output from a compute node. I need to access the surname field which is within an xml string of the element 'Tag'. ie an xml within an xml.
I am still using 2.1( busy with upgrade)
any ideas?
(0x1000010)XML = (
(0x1000000)Tag = (
(0x2000000) = '<?xml version="1.0" encoding="UTF-8"?>
<commissionStatement xmlns:srs="liberty/srs"> <surname>AAAAAAAAAA</surname>
</commissionStatement>' |
|
Back to top |
|
 |
special_agent_Queue |
Posted: Thu Dec 28, 2006 5:42 am Post subject: |
|
|
 Centurion
Joined: 27 Jul 2006 Posts: 102
|
|
Back to top |
|
 |
Lillian |
Posted: Thu Dec 28, 2006 5:51 am Post subject: |
|
|
Centurion
Joined: 15 Apr 2002 Posts: 102
|
I am currenting substringing using the posion of the tag name. Just wondering if there is a cleaner way |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Dec 28, 2006 6:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That's not valid XML.
If you wish to "embed" XML data inside an XML document, and you *don't* want the embedded data to be treated as XML data, then you should put it in a CDATA section.
If you *do* want it to be treated as XML data, then you shouldn't consider it to be "embedded" in anyway, and it should simply be child tags (and not a complete document, per se).
In addition, you won't be ABLE to process this XML data within MQSI 2.1 as XML data - because it's got namespaces in it and 2.1 can't handle namespaces.
Don't bother with this flow or this data in 2.1, build it in your upgrade (which is hopefully v6). _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Lillian |
Posted: Thu Dec 28, 2006 11:49 pm Post subject: |
|
|
Centurion
Joined: 15 Apr 2002 Posts: 102
|
The sample given was a trace output (not actual xml) of the mq message where the data is embedded in the cdata portion. I need to know how to access the field within the cdata.
Is there a better way than finding the position of the tag name and substringing the value into a variable? even in version 6.0? |
|
Back to top |
|
 |
special_agent_Queue |
Posted: Fri Dec 29, 2006 6:26 am Post subject: |
|
|
 Centurion
Joined: 27 Jul 2006 Posts: 102
|
So, what you're saying, is that you DO want to process that cdata. In that case, why don't you parse it?
Something like...
Code: |
CREATE LASTCHILD OF Environment.Variables.TempXML DOMAIN ('XML') PARSE(InputRoot.Tag.(XML.CDataSection).*[1], ccsid, encoding); |
(Of course this hasn't been tested.)
After you do that, then you can access the embedded data like you would with the rest of the message tree.
(And once you move to v6, you can use DOMAIN('XMLNSC') [only if you are using XMLNSC of course] and FolderBitStream! ) |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Dec 29, 2006 7:52 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I don't think 2.1 supports the Create Field PARSE option.
I really doubt 2.1 will parse XML data that has namespaces in it. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Bill.Matthews |
Posted: Fri Dec 29, 2006 8:06 am Post subject: |
|
|
 Master
Joined: 23 Sep 2003 Posts: 232 Location: IBM (Retired)
|
jefflowrey wrote: |
I don't think 2.1 supports the Create Field PARSE option.
I really doubt 2.1 will parse XML data that has namespaces in it. |
The Create Field PARSE was introduced in v 2.1 in the spring of 2002. _________________ Bill Matthews |
|
Back to top |
|
 |
special_agent_Queue |
Posted: Fri Dec 29, 2006 8:17 am Post subject: |
|
|
 Centurion
Joined: 27 Jul 2006 Posts: 102
|
jefflowrey wrote: |
I don't think 2.1 supports the Create Field PARSE option.
I really doubt 2.1 will parse XML data that has namespaces in it. |
I guess I was only half paying attention.
Although, you could just use the double quotes to get around the namespace issue. ie "srs:surname" (not recommended)
However, this is a non-issue since you are upgrading to v6 anyway, and can therefore use xmlnsc. |
|
Back to top |
|
 |
|