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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

911 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

20 Experts available now in Live!

Get 1:1 Help Now