JustinHsu
JustinHsu

Reputation: 13

Error writing XML file in Python appeared AttributeError: 'str' object has no attribute 'dom'

When I was writing xml, appeared this error : AttributeError: 'str' object has no attribute 'dom' I don't know what to do...

enter image description here

Upvotes: 1

Views: 1148

Answers (1)

Laurent LAPORTE
Laurent LAPORTE

Reputation: 22952

When you do import xml.dom.minidom, You import xml. But, your certainly also use xml as a global variable. So, the global variable is hiding the imported module.

Use a different name for your variable, for instance tree or xml_tree are common choices.

Upvotes: 1

Related Questions