# HG changeset patch # User paulb # Date 1103672822 0 # Node ID 6d0b2eff2c6f6d0b99b737a74c35ba97d54717af # Parent 122ee2afead299c1470a28ef38e3f3dbaf21f603 [project @ 2004-12-21 23:47:02 by paulb] Added support for the creation and import of comment nodes. diff -r 122ee2afead2 -r 6d0b2eff2c6f libxml2dom/__init__.py --- a/libxml2dom/__init__.py Tue Dec 21 00:06:51 2004 +0000 +++ b/libxml2dom/__init__.py Tue Dec 21 23:47:02 2004 +0000 @@ -291,6 +291,12 @@ return Node(libxml2.newText(value)) + def createComment(self, value): + # NOTE: Need to convert from Unicode. + value = from_unicode(value) + + return Node(libxml2.newComment(value)) + def _add_node(self, tmp): if tmp.nodeType == xml.dom.Node.ATTRIBUTE_NODE: if tmp.ns is not None: @@ -325,6 +331,9 @@ elif node.nodeType == xml.dom.Node.ATTRIBUTE_NODE: return self.ownerDocument.createAttributeNS(node.namespaceURI, node.name) + elif node.nodeType == xml.dom.Node.COMMENT_NODE: + return self.ownerDocument.createComment(node.data) + raise ValueError, node.nodeType def insertBefore(self, tmp, oldNode):