Others have correctly commented that a SAX parser is the way to go. I'll focus in on something else -- you mention that you want to get elements from the XML really fast.
If that's the case, you ought to be thinking about parsing the document once into a database, then using a database for future access. They're really not all that scary, just grab and install Postgres or something else and you can be on your way.
Databases will be good for you today because you can define indexes for searching, and they will be good for you tomorrow because odds are your "really fast" searching will become "really fast, and pretty complex, and I want to make updates too..." as time goes on.
If you don't use a database, you will need to SAX parse your whole XML document every time, and although SAX is really fast, the I/O alone will kill you. |