首页 > 解决方案 > XML/KML 格式不正确

问题描述

我正在尝试使用以下内容解析 KML 服务:

import requests
import responses
import xml.etree.ElementTree as ET
response = requests.get('http://206.74.144.42/eitms/roadconditions/')
data = str(response.content)
tree = ET.fromstring(data)

但它一直告诉我 XML 格式不正确,如下所示:

not well-formed (invalid token): line 1, column 1

这是什么意思,我该如何解决?使用 Python 3.6。

标签: pythonxmlkml

解决方案


直接调用fromstring(response.content),不使用str().


推荐阅读