Thread: XML vs Database

    #1
  1. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115

    XML vs Database


    Hi guys,

    I was playing a bit around with the php domdocument stuff which made me wondering the following. I noticed that quite some CMS use xml-files to accompany templates, components and plugins (pretty much third party software to extend the cms).

    My question is, is this just done because it's easily (human) readable, (maybe even easier to manage)? Or is there another advantage opposed to storing for instance settings in a database. I can imagine that opening a flat file every time is more time consuming than querying a database that is designed for storing data (so maybe also settings).

    Love to hear what you guys think of it.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,926
    Rep Power
    1045
    Hi,

    XML files are usually used for static configurations that are not supposed to be edited by non-developers. Putting that into the database wouldn't make much sense, because the data is neither dynamic nor meant to be edited through a GUI.

    However, I wouldn't necessarily use the cumbersome XML. JSON or YAML is much more readable.

    Comments on this post

    • aeternus agrees : you're right!
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Hi Jacques1,

    Thanks for the reply. That makes sense; using the Database for dynamic data and xml, json for static data. Should have thought a little longer about it. I am sure though we want to store very crucial static data as variables in a .php-file so it wont be spit out to the browser.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0
    I'm using xml in a mobile game because when I was using php+mysql on my tablet, when the internet was finicky, it made it unplayable. It's just a single player game so if someone takes the time to edit it on their phone so be it. I was considering adding a manual save button that would upload the attributes in the file to mysql.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    xml is recommended

    Comments on this post

    • ManiacDan disagrees
  10. #6
  11. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Originally Posted by peter_solutions
    xml is recommended
    Who cares about Higgs boson, we've found the fifth Trident dentist!
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss

IMN logo majestic logo threadwatch logo seochat tools logo