Ok, I'm new to xml so maybe I don't use the adecuate words, but I hope I make myself clear. I have a large xml document which contains information about files, structured this way: <FILE> <NAME>File1></NAME> <SIZE>5000</SIZE> </FILE> So I have thousands of files in this document, now I want to acces to one file, for example file1, which can be anywhere in the document. Is there a way to do this?? I know I can read the entire document until I find the file, but I'm asking for a more efficient way of doing it. Thanks for the help. [ October 18, 2005: Message edited by: Emili Calonge ]
Many XML technologies (e.g. DOM, XSLT) read the whole file in any case, before you can start looking for particular parts of it. And any solution you come up with is going to have to read at least the whole file down to the part you are looking for. So my suggestion would be to look for a solution that works for you. When you get more experience in XML then you will be able to recognize good and bad solutions.
If all you need out of the XML document is the content of one <FILE> element, this is an ideal candidate for SAX processing. The reasons being: 1. You can abort reading the file after the target information has been found. 2. The memory requirements are much less than the DOM approach which always parses the entire file into memory.