Question:
I often find this strangeCDATA
tag in XML
files:CDATA
tag always comes at the beginning, and then followed by some stuff.But sometimes it is used, sometimes it is not. I assume it is to mark that
some stuff
is the “data” that will be inserted after that. But what kind of data is some stuff
? Isn’t anything I write in XML tags some sort of data?Best Answer:
CDATA stands for Character Data and it means that the data in between these strings includes data that could be interpreted as XML markup, but should not be.The key differences between CDATA and comments are:
- As Richard points out, CDATA is still part of the document, while a comment is not.
- In CDATA you cannot include the string
]]>
(CDEnd
), while in a comment--
is invalid. - Parameter Entity references are not recognized inside of comments.
This means given these four snippets of XML from one well-formed document:
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review