2014-02-05 173 views
0

我有我试图用ElementTree的Python解析XML响应

doc = ET.parse(response_xml) 
    for cust in doc.findall('.//{http://www.starstandards.org/webservices/2005/10/transport}Content'): 
     custnumber = cust.findtext('{http://www.starstandards.org/webservices/2005/10/transport}CustomerNumber') 
     custfname = cust.findtext('{http://www.starstandards.org/webservices/2005/10/transport}FirstName') 
     custlname = cust.findtext('{http://www.starstandards.org/webservices/2005/10/transport}LastName') 
    return custnumber, custfname, custlname 

我试图得到信息的响应解析SOAP响应,我不断收到以下错误:

No such file or directory

response_xml是否需要保存到文件才能解析它?为什么我不能从内存中使用它?

回答

1

ET.parse()需要一个文件名。您可能需要尝试ET.fromstring()

+0

谢谢你,似乎在做伎俩。 – DarthOpto