2014-02-05 215 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