Change the XML library to lxml to avoid namespace renaming and other XML problems
This commit is contained in:
parent
0061b556ec
commit
2886a851e0
@ -359,7 +359,7 @@ class DocxTemplate(object):
|
|||||||
|
|
||||||
for k, v in self.docx.sections[0].part.related_parts.items():
|
for k, v in self.docx.sections[0].part.related_parts.items():
|
||||||
if v.content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml':
|
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)
|
tree = ET.fromstring(v.blob)
|
||||||
for footnote in tree.findall('.//w:t', docx.oxml.ns.nsmap):
|
for footnote in tree.findall('.//w:t', docx.oxml.ns.nsmap):
|
||||||
if hasattr(footnote, 'text'):
|
if hasattr(footnote, 'text'):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user