xml

xml illegal characters - entity replacements

SOFTWARE: xml

< > & ' "

Entity Replacements

Entities to use to replace illegal characters in xml:

&lt;    <   less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark

Using CDATA

Even better: use cdata to escape a whole section so you don't have to worry about it at all! CDATA has its own opening and closing tags, and anything between them will pass through safely. Here's an example of using CDATA within an example xml tag called "contents". Updated per catch noted in comment below (4/2/08)

<contents>
<![CDATA[ content goes here ]]>
</contents>
MORE INFO: http://www.ftponline.com/vsm/2002_11/online/aspnet_jgoodyear_11_05_02/
Comments