Creating xml via Python

Asked by At

I'm trying to make xml file with python library xml.etree.ElementTree But always in result i'm getting file where all tags in on line. Have you meet the same problem? How to make it in classical format?

<Root><tag><tag1 /><tag2 /></tag><Root>

root = xml.Element("Root")
for elem in pathlist:
    if not (root.findall(elem[0])):
        element = xml.Element(elem[0])
    if not (element.findall(elem[1])):
        subelement = xml.Element(elem[1])
tree = xml.ElementTree(root)
with open('result.xml', "wb") as fh:

0 Answers