Hi,I am very new to Python, but having fun learning.
I need to have a script read all of the XML files contents that are in a
directory, pull out the contents of an element, in my case <uicontrol>, and
list them in an output file. I have this script that does exactly what I need.
But in my beginning Python class we didn't go over reading all files, only one
file at a time.
Can the below script be modified to scan/read all of the XML files in a
directory instead of just the file typed into the script? If so, how do I do
this?
Thanks for all the help.Sam
import xml.etree.ElementTree as ETtree = ET.parse('TEST.xml') <-- Want to
read all the files in directory, not type in the filename.root = tree.getroot()
for uicontrol in root.iter('uicontrol'): print(uicontrol.text)
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor