Solved

what's the difference between xml files that use xml elements vs tags with a bunch of attributes?

Posted on 2004-09-07
6
179 Views
Last Modified: 2013-11-19
Hi,

I thought xml files were suppose to  structured so that they were like this:
<Person>
   <name>Pete Smith</name>
   <age>23</age>
</Person>
<Person>
   <name>Mary Jones</name>
   <age>45</age>
</Person>

but my co-worker say they are easier to work with and just as good if you structure them like this:
<Person @name="Pete Smith" @age=23 </>
<Person @name="Mary Jones" @age=45 </>

What's the difference?  We are going to need to use a lot of SQL like selection of different records from the xml files.   Does one method make this easier?  What about xpath, the attributes method seems easier to find data no?

What about schemas and validation of the xml, which method is better for enforcing data validity?

Curious to hear what experienced developers have to say.  Thank you for sharing and helping.

PS.
0
Comment
Question by:keepliving
6 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 55 total points
ID: 12004510
It is easier to work with the normal method. the one u are suggesting. For these reasons

1. It is a standard format accepted by all.

2. Some of the methods like DataSet.WriteXML - writes in this format.

3. When u use some of the methods like Finding the Child element of a node it expects to be in this format.
Eg: - XmlNode.AppendChild and XmlNode.ChildNodes
0
 
LVL 5

Assisted Solution

by:thenrich
thenrich earned 53 total points
ID: 12005483
There are more built class structures in .NET to work with XML vs. the other way
0
 
LVL 7

Assisted Solution

by:Joe_Griffith
Joe_Griffith earned 53 total points
ID: 12006248
The argument between elements and attributes has been going on since the beginning of XML.  Neither is right or wrong.  There is a brief discussion of the issue here:
http://www.xmlfiles.com/xml/xml_attributes.asp

0
 

Author Comment

by:keepliving
ID: 12196575
Hi,

Sorry to abandon this question. I personally do not have an objection to splitting the points.  123654789987 answer was the clearest but the others added to it.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now