Re: Need to escape ]]>

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On 18 Sep., 19:10, Martin Honnen <mahotr...@xxxxxxxx> wrote:
DC wrote:
I have to somehow place this fragment into a CDATA block: ]]>

Example:

<replace><![CDATA[]]></text>]]></replace>

Of course that does not work since the first ]]> will close the CDATA

You need to break that up into two CDATA sections e.g.
<replace><![CDATA[]]]]><![CDATA[></text>]]></replace>

XmlWriter can free you from such hassles by using the WriteCData method
e.g. the above will be created by

writer.WriteStartElement("replace");
writer.WriteCData("]]></text>");
writer.WriteEndElement();

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Perfect, thank you Martin!

Regards
DC

.



Relevant Pages