Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 449
Caz Avatar asked Jun 11 '12 16:06

Caz


1 Answers

>>> 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')]
like image 51
Zashas Avatar answered Nov 18 '22 17:11

Zashas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!