Python 使用LXML读取SOAP响应时出错

Python 使用LXML读取SOAP响应时出错,python,lxml,Python,Lxml,我在尝试读取Soap响应时遇到问题。 它试图读取一些不存在的元素。 有什么问题吗 Python:2.6.6 lxml:2.2.3.0 我的代码: from lxml import etree testFile = open('test.xml', 'r') tree = etree.iterparse(testFile, tag='{http://host.com/Domain}dataRow') for event, elem in tree: print("ID: " +elem

我在尝试读取Soap响应时遇到问题。 它试图读取一些不存在的元素。 有什么问题吗

Python:2.6.6

lxml:2.2.3.0

我的代码:

from lxml import etree

testFile = open('test.xml', 'r')
tree = etree.iterparse(testFile, tag='{http://host.com/Domain}dataRow')

for event, elem in tree:
    print("ID: " +elem.get('id'))
这是我试图阅读的xml:

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns2:GetDataRows xmlns:ns2="http://host.com/Domain">
            <ns2:dataRow id="1"></ns2:dataRow>
            <ns2:dataRow id="2"></ns2:dataRow>
        </ns2:GetDataRows>
</soapenv:Body>
回溯:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
  for event, elem in tree:
  File "iterparse.pxi", line 515, in lxml.etree.iterparse.__next__ (src/lxml/lxml.etree.c:86643)
  File "parser.pxi", line 576, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:64260)
  lxml.etree.XMLSyntaxError: None

这似乎是lxml中的一个bug: