1. XML CDATA Parts that have to be said
All text in an XML document will be parsed by the parser.
Only text within a CDATA part is ignored by the parser.
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.
< |
< |
Less than sign |
> |
> |
Greater-than sign |
& |
& |
And |
' |
' |
Single quotation mark |
" |
" |
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:
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 "]]>".
2, dom4j format escape character problem
Person.xml
<?xml version="1.0" encoding="UTF-8"?>
<person>
<name>张三</name>
<addr><![CDATA[经三路<鑫苑>19F]]></addr>
</person>