XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).
Moderator: General Moderators
RobertPaul
Forum Contributor
Posts: 122 Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY
Post
by RobertPaul » Sun Mar 12, 2006 8:22 pm
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?
vietboy505
Forum Commoner
Posts: 53 Joined: Wed Feb 22, 2006 9:30 am
Post
by vietboy505 » Tue Mar 14, 2006 12:52 pm
I like children rule better.
XML look much nicer.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Mar 14, 2006 2:57 pm
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..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 14, 2006 3:00 pm
from a regex point of view, children is easier to parse
and I believe it's a bit more object oriented too.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Tue Mar 14, 2006 6:35 pm
Children seems more logical, and more scalable.
Mac OSX uses XML with children for all it's kext and config files