Reputation: 330942
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?
Upvotes: 5
Views: 2945
Reputation: 97912
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.
Upvotes: 11
Reputation: 7095
root = et.getroot()
I would recommend using lxml.etree instead of xml.etree.ElementTree, as lxml is faster and the interface is the same.
Upvotes: 4