XML CDATA section.

By Nipun Tomar 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>"

 

 

Nipun Tomar

Nipun is competent and experienced project leader, with 9 years of experience in managing multi-disciplinary teams of varying sizes and complex programs of work. Has the ability to build strong relationships wit... Read more

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs