I have created an XML file using xml.etree.ElementTree. The created XML basically looks like this:
<testsuite name="Exploatering Tests">
<testsuite name="device"></testsuite>
<testsuite name="management"></testsuite>
<testsuite name="auto"></testsuite>
</testsuite>
It all looks good, but I want to export only the child elements into a file and for that I am using the following code:
# First Testsuite Level
testsuite_exploatering = ET.Element('testsuite')
testsuite_exploatering.set("name", "Exploatering Tests")
... HERE I RECURSIVELY ADD LOTS OF ELEMENT TO testsuite_exploatering
# Write XML to file
output_xml = ET.ElementTree(testsuite_exploatering)
ET.ElementTree.write(testsuite_exploatering, output_file, xml_declaration=True, encoding="UTF-8")
It writes the XML element into the file correctly but how should I modify it to print only the inner elements into a file (I don't want to have the Exploatering Tests element written to the file). want the file to look like this:
<testsuite name="device"></testsuite>
<testsuite name="management"></testsuite>
<testsuite name="auto"></testsuite>
No comments:
Post a Comment