-1

CDATA - Used in XML and in Javascript, Is it meaning same in both, that is a sort of comment only ?.

Wasim Khan
  • 1,177
  • 12
  • 13

2 Answers2

1

CDATA actually has two meanings in XML, connected to each other only by some obscure common ancestry in SGML.

It's one of the attribute types you can declare in a DTD - but if you're the kind of person who uses DTDs, then you probably wouldn't be asking this question.

More commonly, it's markup that can occur in the body of the document.

<a>Some <![CDATA[cdata text]]></a>

It's best to think of this as an alternative way of escaping special characters. If there aren't any special characters, as in this example, then it's equivalent to

<a>Some cdata text</a>

But with special characters:

<a>Some <![CDATA[cdata text & ampersands]]></a>

it's equivalent to

<a>Some cdata text &amp; ampersands</a>

Applications are supposed to treat these two as equivalent, but some APIs allow an application to see the difference, so you'll find some badly-written applications that work with one form and not the other.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
-1

The information contained in CDATA provide a way to tell the parser that there is no markup in the characters contained by the CDATA section.

Check these references here:

Community
  • 1
  • 1
Rohit416
  • 3,416
  • 3
  • 24
  • 41