I'm trying to query some very large XML files (up to several gig), check them for being well-formed, and write them to hard disk. Seems easy, but as they are so large I can not have a whole document in the memory. Therefore my question is: How can I read, check and write large XML files when less RAM is available than one document is in size?
My Approach: Read it node by node with XMLReader (if that succeeds the document must be well-formed) and use XMLWriter for writing. Problem: XMLWriter seems to store everything in RAM till the document is finalized. DOM Documents and SimpleXML seem to do the same. Is there anything else I could try?