Forum Discussion

Piyush's avatar
Piyush
New Contributor III
8 years ago

Passing Cdata to xml

Ho wcan I pass CDATA to SOAP execute

3 Replies

  • tk421_cogenics's avatar
    tk421_cogenics
    New Contributor II

    Seriously, is there a solution to this issue?

    In both SOAP Execute and XML Generator when I declare a CDATA section, it gets ignored and the string that is supposed to be in the CDATA section gets escaped.

    The system to which I am sending data is not decoding the data and accepting "Franks&Beans" literally instead of “Franks&Beans”.

  • bgoodkinTCF's avatar
    bgoodkinTCF
    New Contributor II

    Still looking for an answer here, although I found a workaround.

    In my generator, I want to pass my input document wrapped in a CDATA tag because my InputDocument is an externally-provided XML containing its own XML declaration and I want to preserve it as-is.

    Example "InputObject":

    <?xml version="1.0" encoding="UTF-8"?><root>MyInputObject</root>

    Input (from my XML Generator):

     

    <InputDocument><![CDATA[$InputObject]]></InputDocument>

     

    Output:

     

    <InputDocument>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;root&gt;MyInputObject&lt;/root&gt;</InputDocument>

    The only workaround I've found is to put the following in my XML Generator, then use .replace() in a Mapper:

    Input:

    <InputDocument>_INPUTDOCUMENTPLACEHOLDER_</InputDocument>

     

    Replace:

    $xml.replace("_INPUTDOCUMENTPLACEHOLDER_","<![CDATA["+$original.InputObject+"]]>")​

     Output:

    <InputDocument><![CDATA[<?xml version="1.0" encoding="UTF-8"?><root>MyInputObject</root>]]></InputDocument>