My customer wants to write my xml file as <name>Smith & Jones</name>, not <name>Smith & Jones</name>.
I can't find a quality reference discussing this.
From the XML specification (§2.4):
The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. They are also legal within the literal entity value of an internal entity declaration; see "4.3.2 Well-Formed Parsed Entities". If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&" and "<" respectively.
Since this circumstance fits into none of the stated categories, it is illegal.
Use the CDDATA tag to insert these characters within the XML tags without XML parsing them:
<name>Smith & Jones</name>
becomes
<name><![CDATA[ Smith & Jones ]]></name>
this way you can also put plain html withing xml.
example: http://www.w3schools.com/xml/xml_cdata.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With