For error reporting, I need to store the input message into another XML element. Bascially, this requires me to convert the whole InputRoot.XML element into a text string (including) tags, etc.) and assign it to another element so that it is not picked up as an XML construct, but simply as a literal text string (I want to include it in the body of an e-mail message). Example of desired result follows ( are replaced by  as this forum actual converts the XML in this message, and therefore omits important parts of the message text:
Where the InputRoot.XML contains the TestMessage, and the OutputRoot.XML.Message.Body.Line contains that InputRoot.XML as a delimited string (delimited by single quotes ("'")).
Any input appreciated!
Pinned topic Storing a message's XML into an XML element as text
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-02-05T08:29:53Z at 2013-02-05T08:29:53Z by sunnytech
zhnupy 270002UJX82 Posts
Re: Storing a message's XML into an XML element as text2010-06-16T01:04:01ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
I'm facing same requirement. I manage to write output, however I don't see it as text but as a sequence of codes (ascii codes it seems) of the string.
So the question is, how to 'escape' that stream into actual characters?
hope someone can help
email@example.com 120000CJSH515 Posts
Re: Storing a message's XML into an XML element as text2010-06-17T08:13:03ZThis is the accepted answer. This is the accepted answer.
- zhnupy 270002UJX8
If you want the result as a CHARACTER variable, you can just do this:
DECLARE myBLOB BLOB ASBITSTREAM myRef DOMAIN 'XMLNSC' CCSID 1208
DECLARE myXML CHARACTER CAST myBLOB AS CHARACTER CCSID 1208
However, you should be able to do it in a single step.
( only possible because ASBITSTREAM detects the data type of the target variable )
DECLARE myXML CHARACTER ASBITSTREAM myRef DOMAIN 'XMLNSC' CCSID 1208
I expect the syntax is wrong, but you should get the idea.
sunnytech 2700010AVB11 Posts
Re: Storing a message's XML into an XML element as text2013-02-05T08:29:53ZThis is the accepted answer. This is the accepted answer.Thanks Kimbert, I was having the same problem and resolved it with your guide. Exact syntax is as:
DECLARE options INTEGER BITOR(FolderBitStream, ValidateContent,ValidateValue); -- can be changed.
SET Environment.Variables.EmailBitStreamAbStr = CAST(ASBITSTREAM (InputRoot.XMLNSC.EmailNotification,,1208,,,,options) as CHAR CCSID 1208);
use Trace node to see the output Environment variable in one line xml string.