I'm using javax.xml.parsers.DocumentBuilderFactory to load an XML file. The file contains paired elements like so:
<A></A>
<B></B>
<A></A>
<B></B>
<A></A>
<B></B>
So if I did the following:
Element element = <root node element>
NodeList nodeListA = element.getElementsByTagName("A");
NodeList nodeListB = element.getElementsByTagName("B");
Can I assume the elements are in parallel so I can match them as they were written in the XML file like so:
nodeListA.item(7)
nodeListB.item(7)
Also, one last question. As I'm currently using the sax parser on a set of test data, the xml file I will be using with this program is over 70MB. Last time I tried to load the file with this program, Java runs out of memory and throws me an error: java.lang.OutOfMemoryError: Java heap space
Is there a more efficient alternative for parsing XML?