I have an xml string that I need to parse in python that looks like this:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <PostLoadsResponse xmlns="http://webservices.truckstop.com/v11"> <PostLoadsResult xmlns:a="http://schemas.datacontract.org/2004/07/WebServices.Objects" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Errors xmlns="http://schemas.datacontract.org/2004/07/WebServices"> <Error> <ErrorMessage>Invalid Location</ErrorMessage> </Error> </Errors> </PostLoadsResult> </PostLoadsResponse> </s:Body> </s:Envelope>' I'm having trouble using xmltree to get to the error message of this tree without something like:
import xml.etree.ElementTree as ET ET.fromstring(text).findall('{http://schemas.xmlsoap.org/soap/envelope/}Body')[0].getchildren()[0].getchildren()[0].getchildren()
No comments:
Post a Comment