It's not a secret anymore!
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
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!