How to not load the comments while parsing XML in lxml
Set remove_comments=True
on the parser (documentation):
from lxml import etree, objectifyparser = etree.XMLParser(remove_comments=True)tree = objectify.parse(xmlPath, parser=parser)
Or, using the makeparser()
method:
parser = objectify.makeparser(remove_comments=True)tree = objectify.parse(xmlPath, parser=parser)
Hope that helps.