import lxml.etree as et
import io
s = """<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root SYSTEM "test" [ <!ENTITY tasty "cheese"> 
<!ENTITY eacute "é"> ]>
<root>
<a>&tasty; soufflé</a>
</root>
"""
tree = et.parse(io.StringIO(s))
print(et.tostring(tree, xml_declaration=True, encoding='utf-8'))
Создание типа документа с etree lxml