2012年5月24日 星期四

XML : Different between CDATA and PCDATA

CDATA - (Unparsed) Character Data
The term CDATA is used about text data that should not be parsed by the XML parser.

PCDATA - Parsed Character Data
XML parsers normally parse all the text in an XML document.

Characters like "<" and "&" are illegal in XML elements.



係 XML 世界
所有內容都會被 XML analysis
只有加上 CDATA, <tag> 才會被忽略, 直接交給他程序用
例如 XML 加插 HTML, Javascript 等等
<![CDATA[" and ends with "]]>

而 PCDATA 表示已經ANALYSIS 的數據
佢會自動幫你 replace html escape charater
example:
< should be given as &lt;
> should be given as &gt;
& should be given as &amp;


Remark: *
CDATA 內不可以 contain string "]]>" , "]]>" mean 這個 CDATA section 完
Nested CDATA sections are not allowed.

reference : http://www.w3schools.com/xml/xml_cdata.asp

沒有留言:

張貼留言