Find element with attribute with minidom

前端 未结 3 2239
梦毁少年i
梦毁少年i 2021-02-15 10:07

Given



        
3条回答
  •  名媛妹妹
    2021-02-15 10:48

    Wow, that regex is horrible! As of 2016, there is a .getAttribute() method for each DOMElement that makes things a bit easier, but you still have to iterate through the elements.

    l = []
    for e in elements:
        if e.hasAttribute('name') and e.getAttribute('name') == 'field.len':
            l.append(e)
    

提交回复
热议问题