CDATA segment # pcdata CDATA type in XML

Source: Internet
Author: User
Tags xml parser

The CDATA segment # pcdata CDATA type in XML is similar in text because of the CDATA segment and # pcdata, CDATA. To make it easy for everyone to understand, let's take a look at it. 1. the CDATA segment in XML is similar to the heredoc concept in PHP. All the text in XML documents will be parsed by the parser. entity references will be ignored by the parser only when all the tags in CDATA are marked, when the XML processing program treats it as character data, its syntax is <! [CDATA [content to be ignored by the parser]> example
<? XML version = "1.0" encoding = "UTF-8"?> <People> <! [CDATA [<! --! And [do not have blank between --> <teacher> <Name> androidyue </Name> <sex> boy </sex> <age> 22 </age> <add> & Address; </Add> </techer>]> </People>

When using CDATA segments, note that the numbers of CDATA letters must be larger and cannot be nested. The text content of CDATA segments cannot contain "]>" string, "<! [CDATA ["medium "! "And" ["cannot have blank, end"]> "cannot have blank or line feed

2. # In the element type declaration, pcdata declares the element type as # pcdata, indicating that the content of this element is parsed character data and cannot contain subclasses under this element, as shown in <! Element name (# pcdata)> note that there must be more than one space between the name and (") <br/>
3. # The CDATA type CDATA is the most common attribute type, indicating that the attribute can be any text string, but does not include "<" and double quotation marks "> ", to use these two symbols, you can use the entity reference "& lt;" and "& quot;". The syntax is as follows <! ATTLIST element name attribute name CDATA attribute type> As shown in <! ATTLIST Student name CDATA # required> conclusion: The CDATA segment can be understood as a character area, and its internal content XML parser is treated as a string. # pcdata is used to declare the element type, CDATA indicates the property type. <br/>

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.