[英]Python Parsing XML Response
我有一個SOAP響應,我正在嘗試用ElementTree
解析
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
我正在嘗試從響應中獲取信息,並且不斷出現以下錯誤:
No such file or directory
在解析該文件之前,是否需要將response_xml
保存到文件中? 為什么我不能只從內存中使用它?
ET.parse()
需要一個文件名。 您可能要嘗試使用ET.fromstring()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.