File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XML as database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML as database" Watch "XML as database" New topic

XML as database

Swathi Kota
Ranch Hand

Joined: Jun 04, 2008
Posts: 52
Hi all,
We are developing an application for which I am asked to use XML as database instead of the standard relational DBs like SQL.

Can anyone guide me as to where to start?how can i insert and update data into XML?Suggest me good books,links or anything useful.
Thanks in advance !

Success is how high you bounce when you hit bottom
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
Hi Swathi,

If you have static XML document that is not going to change, its ok to use
that.Using XML as database is not a good/preferred option because of
following obvious reasons:

1- Inefficient for dynamic documents.
2- More disk space is required to store XML documents, because of
3- It is not practical for insert/update/delete operation as you need to
load entire XML document into memory (eg. using DOM) and modify its nodes as
required. After that you need marshal that document again into disk.
It is resource intensive and time consuming task.
4- You won't get benefits of relational database.

Generally XML is generated lookup into database or any data source
on the fly as per required depending upon user request for example.
[ November 05, 2008: Message edited by: Chandra Bhatt ]

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Number 4 would be top of my list. Using an XML file(s) instead of a relational (or otherwise) database means your data store is:
  • non transactional
  • not available in distributed environments
  • will struggle to support concurrent access
  • does not guarentee ACID behaviour

  • etc.

    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Paul Clapham

    Joined: Oct 14, 2005
    Posts: 19973

    Here's a link to the Wikipedia article about XML databases. If you read it, you will see that the strategy of storing all your data in a single monster XML document isn't described there. I think that's because (as already mentioned by earlier posters) it really isn't a very good idea at all.

    But your task is just to "use XML as database". That doesn't necessarily mean one monster XML document anyway. It could mean something sensible. It could mean a lot of things. Perhaps you should clarify the requirements before you start designing (or buying).
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    An XML-based file format as a database can be an effective solution. It really depends upon the requirements and how the data will be processed, i.e. created, updated, edited, deleted.

    SGML-based databases have been around a very long time. Typically in the GB range. There are more efficient technoglogies than Java however. Do a search for OmniMark programming language.

    Check out the Apache Digester component

    Checkout Apache XMLBeans

    Checkout the XML Cover Pages
    [ November 06, 2008: Message edited by: James Clark ]
    I agree. Here's the link:
    subject: XML as database
    It's not a secret anymore!