Attribute name "object" associated with an element type "xml.dom.minidom.Document" must be followed by the ' = ' character. Error from API

13 views Asked by At

I solved my own issue and want to share it. I hope it saves you some time.

TLDR: You get this error if you pass a minidom Document object instead of a string to the parser.

During submission of an XML Document via API using a standard HTTP PUT Request via Python, I encountered the following error message in the return XML:

<message>Attribute name &quot;object&quot; associated with an element type &quot;xml.dom.minidom.Document&quot; must be followed by the ' = ' character.</message>

I do not know what XML parsing tool was being used by the receiving API.

I had seen numerous SO posts about special character parsing or poorly formatted XML. I checked my XML rigorously as it possessed numerous special characters and complex attributes.

No changes to the content of the XML resulted in a 200 response.

The problem was actually solved by parsing the minidom Document to a string, then passing the string to the API.

Python interpreted the object ID string output as XML: <xml.dom.minidom.Document object at 0x0000000000000000>

Simple input/ output type tracing solved the issue, but the error handling on this one is somewhat misleading when you are searching for non-extant attributes and elements in your XML, or you actually have an "object" attribute in your XML. :/

0

There are 0 answers