Hello everyone,

I am a student trying to work with the various Java APIs for parsing XML. Being new to the area, I have some basic questions as I study and implement these methods.I did some research to find answers to my questions, but could not find answers to some of them. I hope I will find some answers here. So here are my questions:

- SAX parsing is said to be very memory efficient when compared to DOM. But SAX still requires some memory. Why does it need this memory?

-Also SAX allows us to terminate when our required criterion is met. Does this mean that the rest of the document is not parsed to check for well-formedness/ validity? Because, as I understand it, the SAX parser steps throught the XML document, generating events when significant data is encountered. So if we stop when our condition is met, does the parsing also stop?

- Why does DOM take so much memory?(much more than the actual XML file) Is it because of the object reprsentation of the XML elements/attributes. Does DOM also need the XML file in memory? What does in-memory tree representation of an XML file actually mean?

- If we are parsing an XML file with a Schema, does DOM need to parse the Schema as well and create an in-memory reprsentation?

- How do the memory requirements of SAX and StAX differ and why?

I have observed in working with these methods that DOM takes wayyyyy tooo much memory than the actual XML file. I also have observed that Stax takes little more memory than SAX but less time to parse. Why is that so?

Any help on these topics will be greatly appreciated. I really need help on these. Thanks a lot in advance.