XML Portal Tutorial: XMLCDATA

Source: Internet
Author: User
The text in all XML documents will be parsed by the parser. Only the text in CDATA section (CDATAsection) will be neglected 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 neglected 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, just like The element contains two other elements (first and last ):

 
  
   Bill
  
  
   Gates
  
 

The parser will break it into sub-elements like this:

    
  
   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 will describe it as the beginning of a new element. Therefore, you cannot write as follows:

 
  if salary < 1000 then
 

To avoid this error, you need to replace '<' with an object reference, as shown in the following figure:

 
  if salary < 1000 then
 
There are 5 predefined entity references in XML:< <小于> > Ampersands (&) and ampersands (&) are enclosed in quotation marks (').

Note:Strictly speaking, it is invalid to have only the characters '<' and '&' in XML. Ellipsis, quotation marks, and greater than signs are justified, but it is a good habit to replace them with entity references.

CDATA

Everything inside CDATA is neglected by the parser.

Assume that your text contains a large number of '<' and '&' characters, just as it is often displayed in programming code-then this XML element can be defined as a CDATA.

CDATA section begins''</EM>,结束于<EM>'':

《script》function matchwo(a,b){if (a < b && a < 0) then   {   return 1   }else   {   return 0   }}《script》

In the preceding example, everything in the CDATA section is neglected 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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.