How to organize XML files and difference to Database

Posted on 2006-04-12
Last Modified: 2008-03-10
I'm trying to learn XML and use it on a site with many articles that can be modified after being created.

1) Should I have a folder in my site to save all the articles, one article per XML file, or should I put all the articles in a single XML file?

2) Is it faster or better to save the information for the articles in a database or in an XML file?

You see, every article is going to have different parts (paragraphs, images, etc.) and any part can be modified or deleted, and more parts can be added to the article at any time (For the images, I'm just going to save the URL and save the image in a folder).
Question by:cindyrod
    LVL 12

    Accepted Solution

    This really depends on the size of your articles, and the number of articles you intend to have.

    Knowing nothing else, I'd recommend one xml file per article; benefits:
    Easier to load/save a single article, instead of all the articles.
    Easy to modify a single article without changing anything else.

    Harder to search through; however, you could overcome this with indexes.

    Would you have an xml directory file pointing to the rest of these articles?

    2) A large benefit of XML to Databases is the embedded structure of xml, which automatically implies relationships between parts and parent elements. eg paragraphs and images are tied to an article by the file structure instead of having to have a table to layout all the relationships.
    Furthermore, an article in XML is more easily converted to an HTML page, perhaps through XSLT or other methods.
    LVL 1

    Author Comment

    1) I guess I can have an xml directory file pointing to the articles, how would I do that? Is it just an XML file with the ID of all the articles or is it some kind of special XML file?

    2) Would you recommed to just load the XML file with XSLT to display it correctly or would it be better to parse through the file and display it using a server side language? (Does this make sense?)

    LVL 12

    Assisted Solution

    1) I was originally thinking of just an xml file with the id's. It really depends on what you want to do with your articles, eg, if you wanted to have a quick rss like summary of your articles. This need not even be in xml format.

    2) If there are going to be many views of this page, I recommend converting the page on the server. You can store the result of converting the xml to html.
    So when someone requests the page, you can check the dates of the result file and the xml file, and only re-run the transformation when necessary.

    Hope this helps.
    LVL 1

    Author Comment

    Thank you so much for your help. That was exactly what I needed to know. THANKS!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now