I am trying to allow a user pick the XML file that they would like to parse and use a generic parser to accomplish the task. The code is taken from different websites, just wondering if the code I have so far can be integrated and if so how?
Any help and advice would be greatly appreciated as I am a beginner.
Code:
import Tkinter,tkFileDialog
import os
from xml.etree import ElementTree as ET
root = Tkinter.Tk()
file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Choose a file')
root.mainloop()
def XMLReader( file ):
xml_file = file
tree = ET.parse(xml_file)
try:
tree = ET.parse("sar")
except Exception, inst:
print "Unexpected error opening %s: %s" % (xml_file, inst)
return
Comment