Author |
Message
|
seeknee |
Posted: Wed Jul 09, 2003 6:44 am Post subject: Removing CDATA |
|
|
 Apprentice
Joined: 08 Aug 2002 Posts: 41 Location: Melbourne, Australia
|
Hi All
How do you remove CDATA from an XML element ???
I am receiving a XML message that has CDATA in one of the elements, I want to remove this.
Any help would be appreciated |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jul 09, 2003 7:53 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Do you want to remove the element entirely, or convert it from being a CDATA element to being a non-CDATA element?
The first should be something like
Code: |
set OutputRoot.XML.Message.CDATAElement = NULL; |
The second should be something like
Code: |
set OutputRoot.XML.Message.NewElement = InputRoot.XML.Message.CDATAElement.(XML.CDataSection); |
.
But if your CDATA element contains invalid XML data, your message will throw an error when you try and use that element, either within your ESQL or when you try to write the message to the output queue. |
|
Back to top |
|
 |
basva |
Posted: Wed May 19, 2004 9:30 am Post subject: |
|
|
Apprentice
Joined: 27 Nov 2002 Posts: 39
|
Hi Jeff,
I tried this to remove the CDATA but it is not working. Am I making any mistake here.
Code: |
SET OutputRoot.XML.A.B = InputRoot.XML.A.B.(XML.CDataSection); |
Input
<A><B><![CDATA[<C>cee</C>]]></B><Z>zee</Z></A>
Output
<A><Z>zee</Z></A>
Thanks
Satish
Last edited by basva on Wed May 19, 2004 11:23 am; edited 2 times in total |
|
Back to top |
|
 |
JT |
Posted: Wed May 19, 2004 11:06 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
basva,
The following statement:
Code: |
SET OutputRoot.XML.A.B.(XML.AsisElementContent) = InputRoot.XML.A.B.(XML.CDataSection); |
produces this output message:
Code: |
- <A>
- <B>
<C>cee</C>
</B>
</A> |
|
|
Back to top |
|
 |
basva |
Posted: Wed May 19, 2004 11:32 am Post subject: |
|
|
Apprentice
Joined: 27 Nov 2002 Posts: 39
|
Thanks JT. Thanks for your help. It is working great.
I have one more question. How to add CDATA. Here is my requirement.
I have
<A><B><C>cee</C><D>dee</D></B></A>
It should become
<A><B><![CDATA[<C>cee</C><D>dee</D>]]></B></A>
Thanks
Satish |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 19, 2004 11:53 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Basva -
To turn a nested tree into a flat string, which is what your example is asking to do, you have to use the ASBITSTREAM function. This function is documented in the readme for CSD04 or later of WMQI 2.1. If you are not running at least CSD04 of WMQI 2.1, then you can't really do this.
So you will have to do something like "Set OutputRoot.blah.(XML.CDATASection) = ASBITSTREAM(InputRoot.Blah.blah.blah..."
Also, please consider starting a new question instead of replying to an out of date question. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
basva |
Posted: Wed May 19, 2004 12:10 pm Post subject: |
|
|
Apprentice
Joined: 27 Nov 2002 Posts: 39
|
Thanks Jeff.
I did the following. But my output is in BLOB.
Code: |
SET OutputRoot.XML.A.B.(XML.CDataSection) = ASBITSTREAM(InputRoot.XML.A.B); |
Input
<A><B><C>cee</C></B></A>
Output
<A><B><![CDATA[3c433e6365653c2f433e]]></B></A>
Am I doing anything wrong here?
Thanks
Satish |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed May 19, 2004 12:43 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes.
You are not reading the documentation for the ASBITSTREAM function...
Add the CCSID parameter, that will fix your problem. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
basva |
Posted: Thu May 20, 2004 5:54 am Post subject: |
|
|
Apprentice
Joined: 27 Nov 2002 Posts: 39
|
Thanks Jeff. I changed the code to following. It is working now. I am happy puppy now
Code: |
CAST(ASBITSTREAM(InputRoot.XML.A.B OPTIONS FolderBitStream) AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding); |
|
|
Back to top |
|
 |
|