Skip to content Skip to sidebar Skip to footer

Lxml Kills My Cdata Sections

I'm batch-converting a lot of XML files, changing their character encodings to UTF-8: with open(source_filename, 'rb') as source: tree = etree.parse(source) with open(dest

Solution 1:

Use the strip_cdata=False option:

import lxml.etree as etree
parser = etree.XMLParser(strip_cdata=False)
with open(source_filename, "rb") as source:
    tree = etree.parse(source, parser=parser)

Post a Comment for "Lxml Kills My Cdata Sections"