Tuesday 17 January 2012

XML CDATA


  • All text in an XML document will be parsed by the parser.
  • Characters like "<" and "&" are illegal in XML elements.
  • But text inside a CDATA section will be ignored by the parser.

A CDATA section starts with "<![CDATA[" and ends with "]]>":

e.g.

<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
  {
  return 1;
  }
else
  {
  return 0;
  }
}
]]>
</script>

  • A CDATA section cannot contain the string "]]>". 
  • Nested CDATA sections are not allowed.


No comments:

Post a Comment