I think the choice between using attributes vs. elements should be based on
the semantics of the data rather than the performance aspect.
I remember reading an article that provided a guideline for using attributes
vs. elements and it was something like use attributes for metadata for the
element node and elements for the actual content.
I am probably bastardizing the originally elegantly put statement here but
you get the gist. The author also mentioned and I agree that the line
between what is metadata and data isn't all that clear always. So you
should use your judgement.
For your example, I guess something like a person's names or SSN may be a
good fit for attributes whereas, what kind of car they drive and where they
live clearly works better as elements.
Just my 2 cents!
Jiho Han
[quoted text, click to view] "Novice" <6tc1@qlink.queensu.ca> wrote in message
news:b80e4a77.0404211246.8a8624a@posting.google.com...
> Hi all, I have to decide on an XML structure going forward. The
> structure is going to house a large amount of data. In the past I've
> always just used the philosophy of "when in doubt use elements" - but
> I just read this article:
>
http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dnexxml/html/xml02212000.asp
>
> And there is some indication that you will gain performance benefits
> from XML that uses attributes rather than elements - example:
>
> <grandparent>
> <parent>
> <child>
> <name>
> tony
> </name>
> </child>
> <name>
> Sarah
> </name>
> </parent>
> <name>
> Tom
> </name>
> </grandparent>
> OR
> <grandparent name='Tom'>
> <parent name='sarah'>
> <child name='tony'>
> </child>
> </parent>
> </grandparent>
>
> Now obviously in the first case you leave it open if you want to have
> a deeper structure to name - like firstName, lastName, middleName,
> alias, etc.
>
> But if we were to assume that the XML structure will never change (I
> know that is unlikely in many scenarios) but if it were to remain the
> same, would there likely be a decrease in parsing time when I use the
> transform method of XSLTransform (the .NET class) - in addition, I am
> passing XPath queries (through a XPathNodeIterator object).
>
> Thanks,
> Novice