I like very much the requests
package and its comfortable way to handle JSON responses.
Unfortunately, I did not understand if I can also process XML responses. Has anybody experience how to handle XML responses with the requests
package? Is it necessary to include another package such as urllib2
for the XML decoding?
requests
does not handle parsing XML responses, no. XML responses are much more complex in nature than JSON responses, how you'd serialize XML data into Python structures is not nearly as straightforward.Python comes with built-in XML parsers. I recommend you use the ElementTree API:
or, if the response is particularly large, use an incremental approach:
The external lxml project builds on the same API to give you more features and power still.