Page 1 of 1
XML: Attributes vs. Children
Posted: Sun Mar 12, 2006 8:22 pm
by RobertPaul
Is there any kind of rule (or general "best practice") regarding the use of attributes vs. children to define values? Just for example:
Code: Select all
<dog>
<name>Fido</name>
<color>Black</color>
<size>Toy</size>
</dog>
vs.
Code: Select all
<dog name="Fido" color="Black" size="Toy" />
Is one "better" than the other?
Posted: Tue Mar 14, 2006 12:52 pm
by vietboy505
I like children rule better.
XML look much nicer.
Posted: Tue Mar 14, 2006 2:57 pm
by John Cartwright
I seriously don't have a very good answer for you, but I think it does look better aesthetically. It seems much easier to interpret, although I'm not sure on the differences when having to parse the xml file considering I've worked little with xml..
Posted: Tue Mar 14, 2006 3:00 pm
by feyd
from a regex point of view, children is easier to parse

and I believe it's a bit more object oriented too.
Posted: Tue Mar 14, 2006 6:35 pm
by Chris Corbyn
Children seems more logical, and more scalable.
Mac OSX uses XML with children for all it's kext and config files
