I am not able to use the pretty_print argument to print the xml. Any idea what could be wrong ?
I am attaching the code sample as well.
Thanks
import xml.etree.cElementTree as etree
import os
def main():
root = etree.Element("root")
Series = etree.SubElement(root, "Element")
SeriesID = etree.SubElement(Series, "Index")
SeriesID.text = "80379"
#print str(etree)
#print(etree.tostring(root, pretty_print=True))
print(etree.tostring(root))
if __name__ == "__main__":
main()
xml.etree.ElementTree.tostring()
does not have a pretty_print
parameter.
lxml.etree.tostring()
on the other hand has a pretty_print
parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.