XML DOM Parser error

When I execute the "A Simple Employee Example" script shown in Parsing XML with Java Libraries | Ignition User Manual

...I get the error:

'com.sun.org.apache.xerces.internal.dom.DeepNodeListImpl' object is not iterable

Yeah, I don't know if the DOM libraries have changes since that was written, but this loop seems to work for the sample:

for i in range(employees.getLength()):
    employee = employees.item(i)
    # Convert the id attribute to an integer
    id = int(employee.getAttribute("id"))
    print("Employee ID:", id)
    print("Name:", employee.getElementsByTagName("name").item(0).nodeValue)
    print("Department:", employee.getElementsByTagName("department").item(0).nodeValue)
    print()
2 Likes

Looking at the examples, the only on that seems to work without modification is the StAX parser at the bottom of the page.

Pinging @Paul.Scott

2 Likes