[XML-SIG] bug in dom.ext.GetElementByID

Rich Salz rsalz@zolera.com
Tue, 17 Apr 2001 12:39:02 -0400


It looks like GetElementyID is pre-NS (at least).  Does the following
rewrite make sense?  At least it works ... 

_id_key = ('', 'ID')

def GetElementById(startNode, targetId):
    '''
    Return the element in the given tree with an ID attribute of the
given
    value
    '''
    snit = startNode.ownerDocument.createNodeIterator(startNode,
NodeFilter.SHOW_ELEMENT, None, 0)
    curr_node = snit.nextNode()
    while curr_node:
        attr = curr_node.attributes.get(_id_key, None)
        if attr and attr._get_nodeValue() == targetId:
            return curr_node
        curr_node = snit.nextNode()
    return None

Just double-checking before I check it in.
	/r$