Consuming HTTP Services in Python Transcripts
Chapter: XML services with requests
Lecture: Concept: Consuming XML data from an HTTP service
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
So to review, working with xml from services is pretty straightforward. Again, because it's the easiest way to do stuff on http,
0:08
we are going to work with requests, and then, we are also going to use the ElementTree, and we are going to call request.get given url,
0:16
that is going to get us the response, remember, check the status code, make sure everything worked out okay
0:21
and then we can get a hold of the actual xml as a string, via response.text and then we are going to use ElementTree and parse it as fromstring,
0:28
and once we have that, we are off to the races, we now have an xml dom in memory and we just do xpath queries against it
0:35
as we saw in the previous section.