XML creation: Part 3

In this guide, I'll be creating an XML file to store the Playstation games I own, and ultimately make the XML file 'pretty' for Web browsers. I've done this in the past, with my vehicle gas XML document.

In part three, I'll be adding the actual data that we'll start with.

Last time ...

In part one, I went over what kind of data would be stored in our XML document.

In part two, I created a structure that I believe will work for the data.

The data

This time, we'll start adding actual data into the XML file.

Listed below are the Playstation 3 games I currently own.

PlayStation Games
Game NameSystemBought AtBought DateBought PriceComments
flOw Expansion Pack (Add-On Content) PS3 Playstation Network 2007.11.20 $2.99  
flOw PS3 Playstation Network 2007.11.17 $7.99 Bought online.
Everyday Shooter (Full Game) PS3 Playstation Network 2007.12.13 $9.99  
Warhawk PS3 Best Buy #59 - Madison 53704 (East) 2007.12.24 $45.99 Bought online, using $15 in reward zone points. Came with headset.
Uncharted: Drake's Fortune PS3 Best Buy #59 - Madison 53704 (East) 2007.12.10 $59.99  
Heavenly Sword PS3 Best Buy #59 - Madison 53704 (East) 2007.11.19 $53.99 10% off coupon used
MotorStorm PS3 Best Buy #208 (West Madison) 2007.11.17 $0.00 Came with PS3.

Importing the data

Now that we know what we need to enter, it's just a matter of actually adding it. You can use a tool to do this, but, for now, I'll just manually enter it in.

The new XML file

Skipping ahead, here's the XML file with the seven records added.

With the exception of adding an 'id,' the XML file shouldn't contain anything that wasn't in the first iteration.

Next time ...

You may or may not have noticed (you probably didn't) that the file won't validate. In part four, we're make this validate according to a Document Type Declarations/Definitions (DTD).

While we could work with layout first, I think validation is much more important ...