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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

807 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