I recently started editing XML's using Python and I am still finding it quite tricky...
Now I finished my script and tested it first manually. It worked. Then I tried to run the script entirely but received an error that didn't occur before.
I provided a minimal example here:
import glob
import os
import sys
import xml.etree.ElementTree as ET
curgraph = "somefolder/somefolder/editedGraphPath_full.xml"
tree = ET.parse(curgraph)
root = tree.getroot()
i=0
for file in root.iter('file'):
i = i+1
print i
If I run this line by line within Python everything is working just fine. However, if I run it over cmd line, I get this error:
Traceback (most recent call last):
File "/somefolder/somefolder/test.py", line 12, in <module>
for file in root.iter('file'):
AttributeError: _ElementInterface instance has no attribute 'iter'
I tried to use some the related questions an SO but I didn't find anything helpful yet.