I am using module xml.etree
in Python3
to parse an xml
file.
Here is a code sample:
# test.py
import xml.etree.ElementTree as ET
tree = ET.parse('test.xml')
root = tree.getroot()
node = root[0]
<?xml version="1.0.0"?>
<root>
<node>test</node>
</root>
I want to get the position of node
in test.xml
, i.e., line 2, column 5
(or at least line2
).
How can I implement this function?
I skimmed the methods of ElementTree
class, but found no method for it.