The etree contains numerous functions and
class constructors.
To create a comment node, use this constructor:
etree.Comment(text=None)
text
The text to be placed within the comment. When
serialized back into XML form, this text will be
preceded by “<!-- ”
and followed by “ -->”. Note that one space will be added
around each end of the text you supply.
The return value is an instance of the Comment class. Use the .append()
method on the parent element to place the comment into
your document.
For example, suppose bodyElt is an HTML
body element. To add a comment under this
element containing string s, you would use
this code:
newComment = etree.Comment(s) bodyElt.append(newComment)