XML Parsing Failing Every 10 Runs of Code

Consider using the Java native XML handling, which yields an XML Document with standard DOM methods.

https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Document.html

You might find my shared script module a start, used like so:

dom = shared.xml.strToDoc(oxml)