Tuesday, July 05, 2011

Using Attributes VS elements

Thought to scribble here a little bit. Here is what I learned designing a XML object repository

1. For data use child elements don’t use attributes

2. For quarrying purposes – its ok to use attributes. I hate to write

if(attribute==null) –  Smile

Here are some things that I concluded

  • Attributes cannot contain multiple values, child elements can and so that later addition can be less code breaking
  • Attributes are not easily expandable -for future changes
  • Attributes cannot describe structures / hierarchies for data - child elements can
  • attributes are more difficult to manipulate by program code – LINQ / XQuarry works better with element. – that’s just me
  • Attribute values are not easy to test against a DTD

No comments: