Reputation: 1062
As XMLReader in C# has the property of not bringing the whole XML document in memory at once, it seems quite helpful for big sized XML file. Does Java has something like that? I found Java also got a class named XMLReader, but does it do the same? Anybody please clarify.
Thanks
Upvotes: 2
Views: 1332
Reputation: 41127
Actually, Java has an interface named XMLReader. Being an interface rather than a class, it doesn't actually do anything, until it's implemented.
But it's part of the SAX package for parsing, which does not load the entire document, using events triggered by reading the text of the xml.
You might want to read this tutorial to get started with SAX, and/or just search for SAX in google.
There are other XML parsing packages in Java. DOM does load the entire document, so it should be avoided for large files. StAX is a newer option, which is based on a pull system rather than the push used by SAX, but similarly does not load the entire document.
Upvotes: 1
Reputation: 1559
There are two ways of loading XML: DOM document which loads the entire document in memory and SAX parser which reads the XML and uses an handler to analyse the content.
You might take a look at the SAX parser.
Upvotes: 2