Blog

XML CDATA section.

Posted by Nipun Tomar Blogs | XML May 12, 2011
The term CDATA is used about text data that should not be parsed by the XML parser.

The term CDATA is used about text data that should not be parsed by the XML parser. In other words All data is normally parsed in XML but if you want to exclude some elements you will need to put those elements in CDATA. Characters like "<" and "&" are illegal in XML elements. A CDATA section starts with "<![CDATA[" and ends with "]]>":

In the example below everything inside the CDATA section is ignored by the parser.<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
  {
  return 1;
  }
else
  {
  return 0;
  }
}
]]>
</script>

Another example, the following Cdata section:

    <![CDATA[<greeting>Hello, world!</greeting>]]>

is represented by a CDataSection element with a string value of:

    "<greeting>Hello, world!</greeting>"

 

 

COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.