XPath itself is not very efficient when it comes to iterating through large XML documents. I myself made the experience that it took about 10 seconds to parse the values ββfrom ~ 200 kb of the XML file on the younger device.
After that, I redefined the parser as SAXParser and had a huge performance increase of about 2 orders of magnitude. Therefore, I suggest you try SAXParser. In fact, this is not so difficult to implement, and there are several tutorials.
There is also a stackoverflow question that addresses the topic of various parsing methods: SAX vs. DOM vs. XPath
I also assume that evaluation is done as soon as possible when you are not using NodeSet, because it will search for only one node and return as soon as it finds the corresponding node.
EDIT:
Parsing an XML document with SAX means that you iterate over it and store the information you need in objects. Take a look at this tutorial: SAX Tutorial
There, the author parses information about the staff and converts it into objects, so I think that is exactly what you need.
snrlx source share