The text in all XML documents will be parsed by the parser. Only the text in CDATA section (CDATAsection) is ignored by the parser. ParsedDataXML parser parses all the text in the XML document. When an XML element is parsed
The text in all XML documents will be parsed by the parser.
Only the text in the CDATA section is ignored by the parser.
Parsed Data
The XML parser parses all the text in the XML document.
When an XML element is parsed, the text between tags is also parsed:
This article will also be parsed
The parser does this because the XML element can contain other elements, as in this example The element contains two other elements (first and last ):
Bill Gates
The parser will break it into sub-elements like this:
Reference content is as follows:
Bill
Gates
Escape characters
Invalid XML characters must be replaced with entity reference ).
If you place a character in an XML document, such as "<", this document produces an error because the parser interprets it as the beginning of a new element. Therefore, you cannot write as follows:
If salary <1000 then
To avoid this error, replace the character "<" with the object reference, as shown in the following figure:
If salary <1000 then
There are 5 predefined entity references in XML:
<Less
> Greater
& And number
''Ellipsis
"" Quotation marks
Note: Strictly speaking, it is invalid to have only the characters "<" and "&" in XML. Ellipsis, quotation marks, and greater than signs are valid, but it is a good habit to replace them with entity references.
CDATA
Everything inside CDATA is ignored by the parser.
Assume that your text contains a large number of "<" and "&" characters-just as often occurs in programming code-then this XML element can be defined as a CDATA.
CDATA section starts"",结束于"":
Reference content is as follows:
Script
<br />function matchwo(a,b)<br />{<br />if (a < b && a < 0) then<br /> {<br /> return 1<br /> }<br />else<br /> {<br /> return 0<br /> }<br />}<br />
Script
In the preceding example, everything in the CDATA section is ignored by the parser.
CDATA section comment:
CDATA segments cannot contain strings "]>". Therefore, CDATA segments cannot be embedded.
At the same time, make sure that there are no spaces or lines in the "]>" string.