This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes CDATA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "CDATA" Watch "CDATA" New topic


Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Sorry for asking a dumb question! Why do we need CDATA in XML when we can use "& lt;" and "& rt;".

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
That's a good question. We might manage without CDATA but I still think it's useful. Consider a large text block containing hundreds and hundreds of special characters you need to encode as an entity reference. Without CDATA, you would need to do a lot more string manipulation compared to using CDATA. With CDATA, you only need to encode the ]]> into [[>

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: CDATA
It's not a secret anymore!