sport.xml is
<sports>
<sport order="001">
<name>football</name>
<orgin>England</orgin>
</sport>
<sport order="002">
<name>baseball</name>
<orgin>America</orgin>
</sport>
</sports>
I want to append an element
<?xml version="1.0" encoding="UTF-8" ?>
to xml’s lead
As a result,I want to make a xml like
<?xml version="1.0" encoding="UTF-8" ?>
<sports>
<sport order="001">
<name>football</name>
<orgin>England</orgin>
</sport>
<sport order="002">
<name>baseball</name>
<orgin>America</orgin>
</sport>
</sports>
I wrote codes,
import xml.etree.ElementTree as ET
tree = ET.parse('c:\\pg\sport.xml')
root = tree.getroot()
but I cannot do it. How should I write codes to append the element to xml’s lead?