# XML Parsing Failing Every 10 Runs of Code

**URL:** <https://forum.inductiveautomation.com/t/xml-parsing-failing-every-10-runs-of-code/21838>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [January 12, 2019, 3:58am UTC](https://forum.inductiveautomation.com/t/xml-parsing-failing-every-10-runs-of-code/21838 "2019-01-12T03:58:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [January 12, 2019, 3:58am UTC](https://forum.inductiveautomation.com/t/xml-parsing-failing-every-10-runs-of-code/21838/1 "2019-01-12T03:58:03Z")

</div>

Ignition Version 7.9.10 Trial Version

I am doing some very basic xml parsing and I keep running into an error:

```
oxml = """<PIM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.summitekinstruments.com" xsi:schemaLocation="http://www.summitekinstruments.com PIMXMLSchema.xsd">
	<Responses Legacy="false">
		<Response Action="GetProducts" Units="">
			<Status Error="true" Code="0">
			<Message>This session is not connected to an instrument</Message>
			</Status>
		</Response>
	</Responses>
</PIM>
"""

from xml.etree import ElementTree as ET

root = ET.fromstring( oxml )

```

… and this yields the following error exactly every 10 runs …  
Java Traceback:

```
	at org.python.core.Py.JavaError(Py.java:495)

	at org.python.core.Py.JavaError(Py.java:488)

	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:188)

	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:204)

	at org.python.core.PyObject. __call__ (PyObject.java:387)

	at org.python.core.PyObject. __call__ (PyObject.java:391)

	at xml.parsers.expat$py. __init__ $3(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py:139)

	at xml.parsers.expat$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py)

	at org.python.core.PyTableCode.call(PyTableCode.java:165)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:301)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:194)

	at org.python.core.PyFunction. __call__ (PyFunction.java:387)

	at org.python.core.PyMethod.instancemethod ___call__ (PyMethod.java:220)

	at org.python.core.PyMethod. __call__ (PyMethod.java:211)

	at org.python.core.PyMethod. __call__ (PyMethod.java:206)

	at org.python.core.Deriveds.dispatch __init__ (Deriveds.java:19)

	at org.python.core.PyObjectDerived.dispatch __init__ (PyObjectDerived.java:1057)

	at org.python.core.PyType.type ___call__ (PyType.java:1565)

	at org.python.core.PyType. __call__ (PyType.java:1548)

	at org.python.core.PyObject. __call__ (PyObject.java:404)

	at org.python.core.PyObject. __call__ (PyObject.java:408)

	at xml.parsers.expat$py.ParserCreate$1(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py:59)

	at xml.parsers.expat$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py)

	at org.python.core.PyTableCode.call(PyTableCode.java:165)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:149)

	at org.python.core.PyFunction. __call__ (PyFunction.java:327)

	at xml.etree.ElementTree$py. __init__ $81(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py:1160)

	at xml.etree.ElementTree$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py)

	at org.python.core.PyTableCode.call(PyTableCode.java:165)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:301)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:194)

	at org.python.core.PyFunction. __call__ (PyFunction.java:387)

	at org.python.core.PyFunction. __call__ (PyFunction.java:381)

	at org.python.core.PyInstance. __init__ (PyInstance.java:120)

	at org.python.core.PyClass. __call__ (PyClass.java:194)

	at org.python.core.PyObject. __call__ (PyObject.java:371)

	at org.python.core.PyObject. __call__ (PyObject.java:375)

	at xml.etree.ElementTree$py.XML$69(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py:977)

	at xml.etree.ElementTree$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py)

	at org.python.core.PyTableCode.call(PyTableCode.java:165)

	at org.python.core.PyBaseCode.call(PyBaseCode.java:134)

	at org.python.core.PyFunction. __call__ (PyFunction.java:317)

	at org.python.pycode._pyx31.f$0(<buffer>:15)

	at org.python.pycode._pyx31.call_function(<buffer>)

	at org.python.core.PyTableCode.call(PyTableCode.java:165)

	at org.python.core.PyCode.call(PyCode.java:18)

	at org.python.core.Py.runCode(Py.java:1275)

	at org.python.core.Py.exec(Py.java:1319)

	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)

	at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)

	at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)

	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:476)

	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:464)

	at javax.swing.SwingWorker$1.call(Unknown Source)

	at java.util.concurrent.FutureTask.run(Unknown Source)

	at javax.swing.SwingWorker.run(Unknown Source)

	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

	at java.lang.Thread.run(Unknown Source)

Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

	at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)

	at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)

	at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.lang.reflect.Method.invoke(Unknown Source)

	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:186)

	... 56 more

Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

	at java.net.URLClassLoader.findClass(Unknown Source)

	at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)

	at java.lang.ClassLoader.loadClass(Unknown Source)

	at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)

	at java.lang.ClassLoader.loadClass(Unknown Source)

	at org.xml.sax.helpers.NewInstance.newInstance(Unknown Source)

	... 62 more

Traceback (most recent call last):
  File "<buffer>", line 15, in <module>
  File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py", line 975, in XML
	parser = XMLTreeBuilder()
  File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py", line 1133, in __init__
	self._parser = parser = expat.ParserCreate(None, "}")
  File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py", line 59, in ParserCreate
	return XMLParser(encoding, namespace_separator)
  File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py", line 91, in __init__
	self._reader = XMLReaderFactory.createXMLReader(_xerces_parser_name)
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

	at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)

	at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)

	at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.lang.reflect.Method.invoke(Unknown Source)

org.xml.sax.SAXException: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

```

Attempts:

- validate XML formatting
- restart ignition

Thoughts?

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [January 14, 2019, 1:41pm UTC](https://forum.inductiveautomation.com/t/xml-parsing-failing-every-10-runs-of-code/21838/2 "2019-01-14T13:41:15Z")

</div>

This has been a long time bug that keeps going away and coming back. I get the same thing but after years have still not found a repeatable way to replicate the issue.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 14, 2019, 2:53pm UTC](https://forum.inductiveautomation.com/t/xml-parsing-failing-every-10-runs-of-code/21838/3 "2019-01-14T14:53:34Z")

</div>

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](https://docs.oracle.com/javase/8/docs/api/org/w3c/dom/Document.html)

You might find my [shared script module](https://www.automation-pros.com/ignition/xml.py) a start, used like so:

```auto
dom = shared.xml.strToDoc(oxml)

```
