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 Tomar is competent and experienced project leader & architect with 10 years of experience in managing multi-disciplinary teams of varying sizes and complex programs of work. Has the ability to build strong relation... Read more

COMMENT USING