Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    New to XML - Nesting?

    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>

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    XML is usually not the right way to store data. It's great for communicating data between a server and a client, but it's far too verbose for data storage in most cases. You probably want an actual database, like MySQL.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply. Basically what I was hoping to do was setup the data in an XML document for transfer later on into an SQL or Access Database. My reasoning for this is that I don't have time to really read into SQL/MySQL and I remember reading learning about XML awhile ago and it seemed like a simple and fast way for me to throw in some data and transfer later on. This way I could get some experience using XML in general and also exporting it to different applications.

    Well maybe that's not the best idea, but in either case just out of curiousity I wouldn't mind having your thoughts on the nesting issue too =)

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •