PCDATA 和 CDATA

PCDATA
  parsed character data
  Parsed Character Data, representing the parsed character data, text data should be interpreted as parsed by the XML parser

  XML normally parse all the text in an XML document
  When an XML element is parsed, the text between the tags it will be resolved, such as:

<message>This text is also parsed</message>

 

  In the following example, <name> element contains two additional elements of first and last,

<name><first>Bill</first><last>Gates</last></name>

  The parser will break it down into the following this:

<name>
    <first>Bill</first>
    <last>Gates</last>
</name>

 


CDATA

  Character Data, represent (unresolved) character data, can be understood as textual data should not be parsed by the XML parser

  All text in an XML document will be parsed by the parser, but the text in the CDATA section except

  Like "<" and "&" characters are illegal in XML element
    "<" will generate an error because the parser will interpret the character as the start of the new element
    "&" will generate an error because the parser will characters are interpreted as the start character entities
  Thus, for example, it contains a lot of "<" or "&" character in the JavaScript code in
  order to avoid parsing errors, script code is defined as CDATA
  so, all content CDATA section will be parser ignore


  Format:
    CDATA portion "<[Start CDATA [!", A "]]>" from the end

    <! [CDATA [
      ...
      overlooked parser character
      ...
    ]]>

<Script> 
    ! < [CDATA [
         function matchwo (A, B)   // whole experience matchwo function is ignored by the parser 
        {
             IF (A <B && A <0 ) the then 
            { 
                return . 1 ; 
            } 
            the else 
            { 
                return 0 ; 
            } 
        } 
    ] ] > 
</ Script>

Notes on CDATA section:
  CDATA section can not contain the string "]]>", does not allow nested CDATA section
  end CDATA section labeled "]]>" can not contain spaces or line

Guess you like

Origin www.cnblogs.com/shiliye/p/12605172.html