Reputation: 17220
If I run the following python on an XML file (see bottom of Q):
import xml.etree.ElementTree as ET
tree = ET.parse('C:\\temp\\test2.xml')
print(tree.getchildren())
I get the error:
AttributeError: 'ElementTree' object has no attribute 'getchildren'
I uploaded the XML to an online validator and it said the XML was fine.
Upvotes: 3
Views: 8603
Reputation: 51
getchildren()
is deprecated.
So use list(elem)
, in your case use list(tree.getroot())
Upvotes: 5
Reputation: 86754
The tree itself has no getchildren()
method.
print(tree.getroot().getchildren())
Note that getchildren()
is deprecated. See the documentation
Upvotes: 4