我想测试 python 中的服务器是否发送了无效的 xml..
代码是
content_element = etree.fromstring(content)
xml 类似:
<data = ""></data>
所以由于“”它是无效的
我认为你不能强迫 xml.etree 接受错误的 xml,但你可以使用
beautifulsoup
读取错误的 xml
from bs4 import BeautifulSoup
soup = BeautifulSoup(content, 'lxml')