Clan57
07-02-2009, 03:59 AM
Hi, I've just started reading about XML and I decided to make a simple beer database to get started. Once I got into it I wanted to add more and more detailed data to the file, but I'm concerned about my formatting, how the data will be displayed and if there's such a thing as too much nesting, I don't want to form any bad habits so I was wondering if the users here could provide some advice.
Here's where the issue starts, I have 1 beer, and that beer comes in different sizes (500ml cans, 330 ml bottles etc.), it also ships in different case sizes (single, six pack, twenty-four) so each size and case has a different price. What would be the best way to store this data? I thought about putting soem of the data in the tags itself such as the <ml650> tag shown below, but I have a feeling that's a bad idea?
TLDR Version: Is there a better way to store this data?
<beerDatabase>
<beer>
<name>Saporro</name>
<alcohol>5%</alcohol>
<country>Japan</country>
<ml650>
<price>
<individual>$2.00</individual>
<six>$12.00</six>
<twelve>$24.00</twelve>
<twentyfour>$48.00</twentyfour>
</price>
</ml650>
<ml330>
<price>
<individual>$1.00</individual>
<six>$8.00</six>
<twelve>$16.00</twelve>
<twentyfour>$32.00</twentyfour>
</price>
</ml330>
<goodness>good</goodness>
</beer>
</beerDatabase>
Here's where the issue starts, I have 1 beer, and that beer comes in different sizes (500ml cans, 330 ml bottles etc.), it also ships in different case sizes (single, six pack, twenty-four) so each size and case has a different price. What would be the best way to store this data? I thought about putting soem of the data in the tags itself such as the <ml650> tag shown below, but I have a feeling that's a bad idea?
TLDR Version: Is there a better way to store this data?
<beerDatabase>
<beer>
<name>Saporro</name>
<alcohol>5%</alcohol>
<country>Japan</country>
<ml650>
<price>
<individual>$2.00</individual>
<six>$12.00</six>
<twelve>$24.00</twelve>
<twentyfour>$48.00</twentyfour>
</price>
</ml650>
<ml330>
<price>
<individual>$1.00</individual>
<six>$8.00</six>
<twelve>$16.00</twelve>
<twentyfour>$32.00</twentyfour>
</price>
</ml330>
<goodness>good</goodness>
</beer>
</beerDatabase>