I am trying to print out the xml doc with pretty_print option. But it thew an error
TypeError: tostring() got an unexpected keyword argument 'pretty_print'
Am I missing something here?
def CreateXML2():
Date = etree.Element("Date", value=time.strftime(time_format, time.localtime()));
UserNode = etree.SubElement(Date, "User");
IDNode = etree.SubElement(UserNode, "ID");
print(etree.tostring(Date, pretty_print=True));
lxml.etree
(lxml
library) and notxml.etree.ElementTree
(the built-inElementTree
Python library)? The former has apretty_print
argument, but the latter does not. – Mythopoeichelp(etree.tostring)
in a console. – Mythopoeic