[Tutor] parsing response from SOAPpy request

Eric Brunson brunson at brunson.com
Sat Sep 1 18:24:24 CEST 2007


Alan Gauld wrote:
> "Sean Cronin" <seancron at gmail.com> wrote
>
>   
>> The response comes back as XML document but when I check it with
>> type(result) it shows the the response is a string.
>>     
>
> Thats right the string is the XML document, just as if you had read it
> from a file with the read() method.
>
>   
>> Does anyone have any suggestions on getting relevant data?
>>     
>
> You need to parse the xml.
>
> The classic way to do that is using DOM or sax parsing,

Bleah.  ;-)

>  but
> Python now has the ElementTree parser which is usually
> much easier to use. Look at the module docs and for a lot
> more detail visit the ElementTree homepage:
>
> http://effbot.org/zone/element-index.htm
>   

I've used ElementTree a tiny bit, but preferred BeautifulSoup as it 
seemed more "pythonic" to me.  You should look at both and pick the one 
that suits you.  BeautifulSoup has the advantage of not choking on 
choking on XML that is not well formed.

e.




More information about the Tutor mailing list