【问题标题】:Getting all attributes of an element with minidom使用 minidom 获取元素的所有属性
【发布时间】:2012-06-11 16:10:14
【问题描述】:

我想获取一个元素的所有属性(不知道属性的名称)。有什么功能吗? 谢谢

【问题讨论】:

    标签: python xml minidom


    【解决方案1】:
    >>> 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')]
    

    【讨论】:

      猜你喜欢
      • 2012-09-22
      • 1970-01-01
      • 2013-01-16
      • 2010-09-23
      • 1970-01-01
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 2020-04-11
      相关资源
      最近更新 更多