[Python-bugs-list] [ python-Bugs-438347 ] minidom getElementsByTagNameNS()

noreply@sourceforge.net noreply@sourceforge.net
Tue, 03 Jul 2001 23:29:37 -0700


Bugs item #438347, was opened at 2001-07-03 14:01
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=438347&group_id=5470

Category: XML
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: minidom getElementsByTagNameNS()

Initial Comment:
from xml.dom.minidom.py

the method getElementsByTagNameNS for the Document
class fails to work for two reasons

1. getElementsByTagNameNS does not call
_getElementsByTagNameNSHelper() properly, it should be

    def getElementsByTagNameNS(self, namespaceURI,
localName):
        return _getElementsByTagNameNSHelper(self,
namespaceURI, localName, [])

for the Element class and


    def getElementsByTagNameNS(self, namespaceURI,
localName):
        rc = []
        _getElementsByTagNameNSHelper(self,
namespaceURI, localName, rc)
        return rc

for the Document class

2. The helper method incorrectly searches on
node.tagName which will contain the xmlns prefix
('ns:node')
to correc this it should compare on node.localName

thus the helper function becomes


def _getElementsByTagNameNSHelper(parent, nsURI,
localName, rc):
    for node in parent.childNodes:
        if node.nodeType == Node.ELEMENT_NODE:
            if ((localName == "*" or node.localName ==
localName) and
                (nsURI == "*" or node.namespaceURI ==
nsURI)):
                rc.append(node)
            _getElementsByTagNameNSHelper(node, name, rc)


note the change is on the following line, it contains
the change from above.

            if ((localName == "*" or node.localName ==
localName) and


enjoy, tim...


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-07-03 23:29

Message:
Logged In: YES 
user_id=3066

These are already correct in the CVS repository; I've added
a little cosmetic consistency in Lib/xml/dom/minidom.py
revision 1.34 (1.26 in the PyXML repository).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=438347&group_id=5470