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.
0:04
Again, because it's the easiest way to do stuff on http,
0:07
we are going to work with requests,
0:10
and then, we are also going to use the ElementTree,
0:12
and we are going to call request.get given url,
0:15
that is going to get us the response, remember,
0:17
check the status code, make sure everything worked out okay
0:20
and then we can get a hold of the actual xml as a string, via response.text
0:23
and then we are going to use ElementTree and parse it as fromstring,
0:27
and once we have that, we are off to the races,
0:30
we now have an xml dom in memory and we just do xpath queries against it
0:34
as we saw in the previous section.