Caz
Caz

Reputation: 81

Getting all attributes of an element with minidom

I would like to get all the attributes of one Element (without knowing the names of the attributes). Is there any function for that? Thanks

Upvotes: 7

Views: 8195

Answers (1)

Zashas
Zashas

Reputation: 766

>>> docu = '<a href="http" alt=":)"></a>'
>>> dom = xml.dom.minidom.parseString(docu)
>>> a = dom.getElementsByTagName("a")[0]
>>> a.attributes.items()
[(u'alt', u':)'), (u'href', u'http')]

Upvotes: 9

Related Questions