Change the XML library to lxml to avoid namespace renaming and other XML problems

This commit is contained in:
Bart Broere 2024-09-17 21:07:21 +02:00 committed by GitHub
parent 0061b556ec
commit 2886a851e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -359,7 +359,7 @@ class DocxTemplate(object):
for k, v in self.docx.sections[0].part.related_parts.items():
if v.content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml':
import xml.etree.ElementTree as ET
from lxml import etree as ET
tree = ET.fromstring(v.blob)
for footnote in tree.findall('.//w:t', docx.oxml.ns.nsmap):
if hasattr(footnote, 'text'):