This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes attribute vs. 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 "attribute vs. CDATA" Watch "attribute vs. CDATA" New topic

attribute vs. CDATA

lajos kamocsay
Ranch Hand

Joined: Aug 12, 2006
Posts: 37

I'm new to XML. I cannot decide if I should save information as attributes or as CDATA. Below are the two versions. Which way should I go and why?


attribute version

CDATA version
shiva kumar

Joined: Aug 22, 2006
Posts: 7
Hi lajos,
You should go for the first one (the attribute version).

Reason: name and password are attributes of a user.

Only if you are not able to represent in the first method you can go for the second method.

You can go for CDATA under following situations.

<Building name="Build1">
<Floor name="Floor1">
<Cabin name="c1"/>
<Cabin name="c2"/>


<Building name="Build1">
<Floor name="Floor1"/>
<Floor name="Floor2"/>

Have you checked out Aspose?
subject: attribute vs. CDATA
It's not a secret anymore!