XML

Escaping Reserved Characters

The XML syntax uses some characters to delimit element tags and attributes. These reserved characters (<, >, &, ", ') therefor need some alternative coding, i.e. to be "escaped", when used within the content of elements or attributes. XML has 5 so called predefined entities (lt, gt, amp, apos, quot) that should be used ("referenced") instead of the reserved characters they represent.

USE THIS INSTEAD OF .
&lt; < less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark

Alternative for escaping single XML reserved characters is to put a whole block of element content that contains reserved characters in a so called CDATA section. CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string "<![CDATA[" and end with the string "]]>":]