ankur rathi wrote:
Let me rephrase my question. What do you prefer? XML file or Database?
Never really thought about it that much. I have done both.
Wrote lots of programs that read and save XML data as XML files.
Wrote some programs that parsed and save XML data in databases. Of course, you can argue that the data wasn't XML data anymore, as it has been parsed.
In a few cases, I did save raw XML data in a database. But in those cases, it was a corporate wide database. It was the best location to store something that was accessabile from everywhere in the company, was kept up at all times, was automatically backed up, and made highly available.
I depends on the amount of data you will be storing. I have used XML files a few times when the amount of data was very small - the XML files never grew larger than 100KB. I usually read the file at startup and re-wrote the file any time any data changed. I expected at most 2 or 3 users, but I still synched the data changes.
I would like to comment on this way from an enterprise application standpoint...
XML files are good for storing configuration parameters which determine connectivity to external applications as you can carry those files always along with the application archive (deployable component)
Databases would be preferred for lookup data and storing those details which you do not wish to package along with the application.
In general databases are by default deemed for storing data while XMLs are more preferred to be used as means of propogating stored data rather than storing as static for frequent retrieval. If XMLs are used to store data then need to look for servers to store the XMLs itself.
Basically, like Praveen, I would store data in an XML document if I planned to update that document as a whole document, occasionally. So it would be useful for configuration files. If I planned to update small pieces of the data frequently, like keeping track of orders for a set of customers for example, I would store the data in a database.
It depends on the type of data being stored. SGML-based or XML-based data files are the best practice for storing text-based content for technical manuals, books, CD-ROM, professional/legal information, etc. In many cases SGML/XML data files are in Giga/Terra byte range.