I'm working with xml.etree.cElementTree, and regarding to official documentation - want find element in Element:
$ python --version
Python 2.7.8
My script:
#!/usr/bin/env python
import os, re
import xml.etree.ElementTree as ET
XML_FILE = '/cygdrive/****.csproj'
try:
tree = ET.ElementTree(file=XML_FILE)
root = tree.getroot()
print type(root)
for item in root.iter(tag='OutputPath'):
print item.tag, item.attrib, item.text
....
But when I run it - have an error:
$ ./xm_par.py
<type 'Element'>
Traceback (most recent call last):
File "./xm_par.py", line 21, in <module>
for item in root.iter(tag='OutputPath'):
TypeError: iter() takes no keyword arguments
What I'm miss here?
No comments:
Post a Comment