Forum Moderators: open
CDATA is "Character Data", and is essentially freeform data that needn't conform to XML syntax. Everything inside a CDATA section is ignored by the parser.
<url><![CDATA[http://www.example.com/index.jsp?pageName=hotInfo&cid=27477&temp1=BBS&hotelID=5595]]></url>
is the same as
<url>http://www.example.com/index.jsp?pageName=hotInfo&cid=27477&temp1=BBS&hotelID=5595</url>
If your data contains a lot of "&" and "<" characters, or if the data is fed in from an external source, it's usually easier to wrap it in a CDATA block instead of running it through a string replacement function.
CDATA also comes to the rescue when your data contains other non-entities like and "
I said the one example was "the same as" the other. of course they're not the same; they validate differently.
the similarity is that they accomplish the same thing and solve the same problem.
it's a good habit to use CDATA sections for user-entered data, javascripts, text content. When the well-formedness + validity of something is uncertain and/or unnecessary.
CDATA is your prophelactic against user-transmitted invalid entities.