XML question

Zucarita9000

Golden Member
Aug 24, 2001
1,590
0
0
I'm creating this XML file for a flash website for a local architect. The flash file handles all the xml parsing functions, and I have to write the xml with all the site's data.

Here's an example. I have to show very basic info for every project, such as Client, Year, Location, etc. What I need to know is wich is the best way to store the data, should I create elements for every item or simply use attributes for a single element?

Using elements:

<project id="01">
<client>Mr. Jones</client>
<year>1999</year>
<location>Malibu</location>
</project>

Using attributes:

<project id="01" client="Mr. Jones" year="1999" location="Malibu"></project>

Both methods are equally valid, but what are the "best practices" when handling XML data? As you may notice, this is the first time I write and XML file.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Use elements when possible. They are easier to manipulate in code and XSLT, and they allow for more complex data storage. W3Schools discusses this topic pretty well.