简体   繁体   中英

Python Parsing XML Response

I have a SOAP response which I am trying to parse with 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  

I am trying to get the information out of the response and I keep getting the following error:

No such file or directory

Does the response_xml need to be saved to a file before I can parse it? Why can't I just use it from memory?

ET.parse() needs a file name. You might want to try ET.fromstring() instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM