Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 220 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 212 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 212 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

604 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