function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RohiniHRohiniH 

When will DOM.Document support CDATA, or is there an alternative

dom.XmlNode tempNode = hdr.addChildElement('Company Name', null, null);

tempNode.addTextNode('ABC & XYZ ');

tempNode = hdr.addChildElement('Company Address', null, null);

tempNode.addTextNode('ABC & XYZ, <former 123ABC> ');

 

The xml created by this gives incorrect output with &amp; &lt; etc

 

i cannot include characters like & and < in DOM.Document's dom.XmlNode

 

Avoiding XMLStreamWriter, as it easily reaches heap limit.

JarrettKuljisJarrettKuljis

I am having to re-write and code to XmlStreamReader due to the fact we don't control the XML feed and have one vendor.  Sucks.

gedeefgedeef

the topic is now old but for next people who search, I made a class who transforms cdata without executing too many lines of code.

it transforms <![CDATA[some text < > end of text]]> to <CDataSection lt="{" gt="}">some text { } end of text</CDataSection> before you load the xml string, and has a method to get the content as it was before transformed.

It's not perfect for all situations but could help.

https://github.com/gedeef/XmlCData

tggagnetggagne
Are there other alternatives to Salesforce's XML.Document than XMLDOM?

http://developer.force.com/codeshare/projectpage?id=a0630000002ahp5AAA

It doesn't look to have been updated, and maybe it's stable, but rather than create my own that supports CDATA tags I thought I'd see if there was another I could borrow.