Link to home
Start Free TrialLog in
Avatar of Dolamite Jenkins
Dolamite JenkinsFlag for United States of America

asked on

what does xml.parsers.expat.ExpatError: not well-formed (invalid token): mean

There is a portion of my program that has to go on the internet and  grab data and I have it working fine and if there is no internet then I just Pass the exception... the problem comes in when the computer is connected to the internet but the computer cant access internet ie needs pass word or must log on.... I get the error below Ive tried to create an excpetion but it doesnt work... so is there another error that I should use to catch this or is there a module I should import ?


xml.parsers.expat.ExpatError: not well-formed (invalid token): line 6, column 75
File "c:\Python26\sign\April_1_version_Reg_Tracker_X.py", line 5969, in <module>
  InsertData(None, -1, 'SEMS Patient Reporting Software ver 0.0.6')
File "c:\Python26\sign\April_1_version_Reg_Tracker_X.py", line 43, in __init__
  self.textentry(self)
File "c:\Python26\sign\April_1_version_Reg_Tracker_X.py", line 409, in textentry
  self.WeatherData()
File "c:\Python26\sign\April_1_version_Reg_Tracker_X.py", line 433, in WeatherData
  google_result = pywapi.get_weather_from_google(self.city)
File "c:\Python26\sign\pywapi.py", line 52, in get_weather_from_google
  dom = minidom.parse(handler)
File "C:\Python26\Lib\xml\dom\minidom.py", line 1918, in parse
  return expatbuilder.parse(file)
File "C:\Python26\Lib\xml\dom\expatbuilder.py", line 928, in parse
  result = builder.parseFile(file)
File "C:\Python26\Lib\xml\dom\expatbuilder.py", line 207, in parseFile
  parser.Parse(buffer, 0)

Open in new window

this is the code Im using now
def WeatherData(self):
	
        try:
	    
            google_result = pywapi.get_weather_from_google(self.city)
           
            self.weather1a =  str(google_result['current_conditions']['condition'])
        except IOError: 
            pass
	except ExpatError:
	    pass

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of shjacks55
shjacks55

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dolamite Jenkins

ASKER

Thanks I figured it out I was placing the code into the wrong module