Original address: http://www.cnblogs.com/zhxhdean/archive/2012/02/08/2342498.html
If you use a character like "<" in an XML document, the parser will get anerror because the parser will assume that this is the beginning of a new element. Therefore, you should not write the code as follows:
<message>if Salary < Then</message> |
To avoid this situation, the character "<" must be converted to an entity, as follows:
Here are five pre-defined entities in the XML document:
< |
< |
|
> |
> |
|
& |
& |
and |
' |
|
single quotation mark |
" |
|
|
The entity must begin with the symbol "&", with the symbol ";" End .
Note: only the "<" character and the "&" character are strictly forbidden for XML. The rest is legal, and the use of entities is a good habit in order to reduce errors.
CDATA Parts
All content inside 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 widget.
A CDATA part to "<![ cdata["tag to start with"]]>"Mark end:
<script><![ Cdata[function Matchwo (b) {if (a < b && a < 0) Then{return 1}else{return 0}}]]></script> |
In the previous example, all the text between the CDATA parts is ignored by the parser.
CDATA Considerations:
CDATA Parts can no longer contain CDATA parts (not nested). If the CDATA part contains the character "]]>" or "<![ Cdata[", will be very likely to make mistakes oh.
Also note thatthere is no space or line break between the string "]]>".
[The escape character in the]xml file