0
我試圖用ElementTree的解析XML,但我得到這個錯誤:解析XML與元素樹
xml.etree.ElementTree.ParseError: encoding specified in XML declaration is incorrect
我file.py:
from suds.client import Client
import xml.etree.ElementTree as ET
url = 'http://www.webservicex.com/globalweather.asmx?WSDL'
client = Client(url)
weather = client.service.GetWeather('Sao Paulo', 'Brazil')
print weather
parseWeather = ET.fromstring(weather) # >>>> Here I got my problem!
當我嘗試解析我的XML從串天氣。任何人都知道如何解決這類問題?
它看起來replace()方法打開'weather'爲一個字符串。 Martijn有正確的答案。 – Rohmer