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

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.


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.


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.

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

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.