Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

attribute vs. CDATA

 
lajos kamocsay
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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?

Thanks,
Lajos

attribute version


CDATA version
 
shiva kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"/>
</Floor>
</Building>

or

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

Regards,
Shiva
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic