1.1 --- a/libxml2dom/__init__.py Fri Apr 06 18:37:16 2007 +0000
1.2 +++ b/libxml2dom/__init__.py Fri Apr 06 18:38:06 2007 +0000
1.3 @@ -20,7 +20,7 @@
1.4 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1.5 """
1.6
1.7 -__version__ = "0.4.2"
1.8 +__version__ = "0.4.3"
1.9
1.10 from libxml2dom.macrolib import *
1.11 from libxml2dom.macrolib import \
1.12 @@ -30,6 +30,7 @@
1.13 toString as Node_toString, toStream as Node_toStream, \
1.14 toFile as Node_toFile
1.15 import urllib # for parseURI in HTML mode
1.16 +import xml.dom # for getElementById
1.17
1.18 class Implementation(object):
1.19
1.20 @@ -363,6 +364,14 @@
1.21 else:
1.22 Node_removeChild(self._node, tmp)
1.23
1.24 + def getElementById(self, identifier):
1.25 + nodes = self.xpath(".//*[@xml:id='" + identifier.replace("'", "'") + "']",
1.26 + namespaces={"xml" : xml.dom.XML_NAMESPACE})
1.27 + if nodes:
1.28 + return nodes[0]
1.29 + else:
1.30 + return None
1.31 +
1.32 def getElementsByTagName(self, tagName):
1.33 return self.xpath(".//" + tagName)
1.34
1.35 @@ -413,6 +422,9 @@
1.36 def isSameNode(self, other):
1.37 return self == other
1.38
1.39 + def __hash__(self):
1.40 + return hash(self.localName)
1.41 +
1.42 def __eq__(self, other):
1.43 return isinstance(other, Node) and libxml2mod.xmlXPathCmpNodes(self._node, other._node) == 0
1.44