Basically I am using:
from xml.etree import ElementTree as ET
path = 'C:\cool.xml'
et = ET.parse ( path )
But I am not sure how to get the root from et?
You probably want:
et.getroot()
Have a look at the official docs for ElementTree from the effbot site. Note that Python 2.5 (the first version of Python to include ElementTree out of the box) uses ElementTree 1.2, not the more recent 1.3. There aren't many differences, but just FYI in case.
root = et.getroot()
I would recommend using lxml.etree instead of xml.etree.ElementTree, as lxml is faster and the interface is the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With