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
181 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

815 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

8 Experts available now in Live!

Get 1:1 Help Now