Python program to remove comments from file

from lxml import tree
XML = """

Hello
World


"""
tree1 = tree.fromstring(XML)
comments = tree1.xpath('//comment()')
for c in comments:
p = c.getparent()
p.remove(c)
print tree.tostring(tree)

Output:
Hello
World