Can anyone let me know what is the exact difference b/w #PCDATA and #CDATA and why #CDATA is not allowed as the content for an element? As far as i understand, #PCDATA will be parsed by the parser and hence cannot contain any mark-up text like --- < > ' ". I also understand that the parser resolves any of the entity references contained within the #PCDATA that it parses. What about #CDATA? Anyone please correct me for any mistakes and clarify
The keywords #PCDATA and CDATA are pretty much equivalent. One is used for elements and one for attributes. Why are they named differently? Good question. The only characters which are not allowed in #PCDATA are < and & (unless it represents an entity reference). The same applies to CDATA. In addition, it can't have " or ', depending on the character that delimits the attribute. One difference between the two is the fact that #PCDATA is a content model, the only one that specifies what the character stream looks like. CDATA, on the other hand, is one of several ways to restrict the attribute's content. Cheers, Dan
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Copied from w3schools PCDATA PCDATA means parsed character data. Think of character data as the text found between the start tag and the end tag of an XML element. PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.
CDATA CDATA also means character data. CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.
Hi Zhang, You have given below text. "CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded. " But.. The internal entity references as an attribute (which is of type CDATA) value will be expanded. Please let me know if am wrong.
Jayadev Pulaparty
Ranch Hand
Joined: Mar 25, 2002
Posts: 645
posted
0
Yeah! Not only the internal entity references, but also the external parsable entity references will be parsed and the value substituted by the parser when entities are used for CDATA of the attributes; "Only text inside a CDATA SECTION is ignored by the parser." - from w3schools I guess the CDATA section is the catch here and not the CDATA type used for the attributes;