python - elementtree.parse() not opening file open() will -
i trying write python script open xml file add elements , exit. can't element tree open file want. able open file open(). example code
try: file = open(projectlocation + "\etc\config\struts-config.xml", 'r') print "oppenned file" #this print tree = et.parse(projectlocation + "\etc\config\struts-config.xml") #this fails print "oppenned xml" except: print "could not open " + projectlocation + "\etc\config\struts-config.xml" sys.exit()
updating code this, comment recieved:
tree = et.parse(projectlocation + "\etc\config\struts-config.xml") print "oppenned xml"
this give me error:
traceback (most recent call last): file "test.py", line 117, in <module> tree = et.parse(projectlocation + "\etc\config\struts-config.xml") file "/usr/lib/python2.6/xml/etree/elementtree.py", line 862, in parse tree.parse(source, parser) file "/usr/lib/python2.6/xml/etree/elementtree.py", line 586, in parse parser.feed(data) file "/usr/lib/python2.6/xml/etree/elementtree.py", line 1245, in feed self._parser.parse(data, 0) xml.parsers.expat.expaterror: mismatched tag: line 1205, column 2
Comments
Post a Comment