# HG changeset patch # User Paul Boddie # Date 1219703682 -7200 # Node ID 1cb2cf8468c6287eca8d321fd23d2c0ed821c043 # Parent 86911bef5658e5b83d0da634b849fb48b3bf1dee Fixed getElementById to actually return the element, not the attribute. Added tests of validation and identifiers. diff -r 86911bef5658 -r 1cb2cf8468c6 libxml2dom/macrolib/macrolib.py --- a/libxml2dom/macrolib/macrolib.py Tue Aug 26 00:17:04 2008 +0200 +++ b/libxml2dom/macrolib/macrolib.py Tue Aug 26 00:34:42 2008 +0200 @@ -490,7 +490,11 @@ ) def Node_getElementById(doc, identifier): - return libxml2mod.xmlGetID(doc, identifier) + node = libxml2mod.xmlGetID(doc, identifier) + if node is None: + return None + else: + return Node_parentNode(node) def Node_xpath(node, expr, variables=None, namespaces=None): expr = from_unicode(expr) diff -r 86911bef5658 -r 1cb2cf8468c6 tests/test_invalid.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_invalid.xml Tue Aug 26 00:34:42 2008 +0200 @@ -0,0 +1,10 @@ + + + ]> + + Also shows off getElementById which needs the DTD. + diff -r 86911bef5658 -r 1cb2cf8468c6 tests/test_valid.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_valid.xml Tue Aug 26 00:34:42 2008 +0200 @@ -0,0 +1,9 @@ + + + ]> + + Also shows off getElementById which needs the DTD. +