So I'm doing it now like this : Searching XML Document for the <Argument> and when I find it, retrieve the ID. which might be started with *cat-*, *loc-* or *pro-*. So now I know the Type of the Argument and show the content corresponding to that type.
Is this a good approach or should I leave it alone and try to query database? I'm having 3 different tables to store them. Is this not gonna make visitors lose some times? because I have to search 3 tables (at the worst scenario!)
In this worst scenario, is it faster to query 3 different tables secuentially, or searching the XML Document?
I'm using Tomcat on linux, and the PL is Java, by the way.
If you just store a big XML document and parse the whole thing every time you get a request, then your response time will be far too long. But if you index the XML document and make some kind of "XML database" out of it, then you might have something workable.
Likewise if you create a database with no indexes, then you would have to search the whole table for every request. That would be a slower-downer too.
However it's very easy to create an index for a database table. Whereas indexing an XML document is not something that you could do this afternoon. If I had the choice of using a database or an XML document to store data which is naturally table-structured and not tree-structured, I would use the database pretty much automatically. And that's what you have, as far as I can tell. I don't see anything to make me choose XML at all.
Joined: Aug 08, 2005
Hi Paul, Thanks for your response. The thing is I kinda have to use the XML. Because this is multilingual Website, and I'm handling the different Language Elements via XML document (Using XML Doc as a Dictionary) - Is this a good approach for multilingual websites ?? - and the usage of XML in the current situation is inevitable for me. So if I would go for the xml solution, you've said I have to index it. I've searched for Indexing XML Document, and I've found different things like: Lucene, Nuch, Compass, Hadoop, ... what are these? am I finding the right path? did you mean one of these?
If you need to locate a particular Element (org.w3c.dom.Element) according to some key word - possibly an attribute or other text, you can use Java collections such as HashMap to store a reference to that Element by that key. This gives mind boggling-ly fast lookups.
More complex look-up for a specific Element might be handled by XPath and XQuery style searches. There is no need to venture outside the standard Java library - see javax.xml.xpath package in Java 1.5 et seq.
subject: XML Reading vs. MySQL Querying. which one should I choose?