Xml
All text in an XML document will be parsed by the parser.
Only text within a CDATA part is ignored by the parser.
Parsing data
XML parsers typically process all the text in an XML document.
When an XML element is parsed, the text inside the XML element is also parsed:
<message>this text is also parsed</message>
The reason the XML parser does this is that the XML element may also contain other elements, as in the following example, the name element contains the first and last two elements internally:
<name><first>Bill</first><last>Gates</last></name>
The parser would consider the above code to be like this:
<name><first>Bill</first><last>Gates</last></name>
Escape character
An illegal XML character must be replaced with the corresponding entity.
If you use a character similar to "<" in an XML document, the parser will get an error because the parser will think that this is the beginning of a new element. So you should not write the code as follows:
<message>if Salary < 1000 then</message>
To avoid this, you must convert the character "<" to an entity, as follows:
<message>if Salary < 1000 then</message>
Here are five entities that are predefined in an XML document:
<< less than sign >> greater than && and ' single quotes ' double quotes
The entity must begin with the symbol "&" with the symbol ";" End.
Note: Only the "<" and "&" characters are strictly prohibited for XML. The rest is legal, and in order to reduce errors, using entities is a good habit.
CDATA Parts
All content within CDATA is ignored by the parser.
If the text contains a lot of "<" characters and "&" characters-just like the program code, it's best to put them all in a CDATA part.
A CDATA part with "<! The [cdata["Mark begins with the"]]> "tag, ending with:
<script><! [Cdata[function matchwo (a,b) {if (a < b && a < 0) Then{return 1}else{return 0}}]]></script>
In the previous example, all text between CDATA parts would be ignored by the parser.
CDATA Considerations:
CDATA Parts can no longer contain CDATA parts (cannot be nested). If the CDATA part contains the character "]]>" or "<! [cdata[], there will be very likely to go wrong oh.
Also note that there are no spaces or line breaks between the string "]]>".