what is xml cdata - all content in an xml document will be parsed by the parser,but all content inside a cdata section will be ignored by the parser.

xml cdata section

the code inside cdata section not be parsed by the xml parser.

a cdata section start with the following sequence      <![cdata[

and ends with the first occurrence of the sequence     ]]>

xml CDATA example

                                          function  multiple(a , b){
                                               if (a<b || a>b)then
                                                {return a+b;}
                                               else {   return 0; }  }                                       
                                          ]]>    </script>

in the above example, the code inside the cdata section is ignored by the parser.

note : a cdata section cannot contain the string "]]>" and therefore it is not possible for a cdata section to contain nested cdata sections.

uses of cdata sections

cdata purpose is to 'protect' data from being treated as ordinary character data during processing.cdata sections are useful for writing xml code as text data within an xml document.

XML pcdata(parsed character data)

the parsed character data is a data definition that originated in sgml, and is used also in xml document type definition(dtd) to designate mixed content xml elements.

in xml dtd, #pcdata is the keyword to specify mixed content, meaning an element may contain character data as well as child elements in arbitrary order and number of occurrences.for example

                                     <!element    a     (#pcdata) >
                                     <!element    s     (#pcdata|a|b|c)* > 

in this code, element <a> must contain character data only;

element <s> can contain a mixture of any combination of character data, <a>, <b>,<c> elements(s).