How can i read a single tag say from a huge xml file(say 5gb) , i dont need other data from xml . Is the Stax approach the right thing ? consider sample xml
<tag1>
<tag2>
<tag3>
<tag4>
.
.
.
.
.
.
.
<balance>12121</balance>
.
.
.
.
.
.
</tag4>
</tag3>
</tag2>
</tag1>
thanks in advance
If you are processing a huge xml files, you need to use a SAX parser, instead of a DOM parser. Look at this tutorial and here in the Oracle page.
Dom parsers - are reading whole documents and creating a structure in memory, they can be used like a map of maps, so very easy to checking if any elements exists, etc. But it;s not effective against big data.
Sax on the other hand are event driven parsers, you implement methods for reading a tag, then reading it velue, etc. It is a one iteration algoritm, that doesn't use much resources.