From the course: Python: XML, JSON, and the Web

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using lxml

Using lxml - Python Tutorial

From the course: Python: XML, JSON, and the Web

Start my 1-month free trial

Using lxml

- [Narrator] For this example, we'll use the LXML module's implementation of the ElementTree API to manipulate the XML content like we did in the dom example. LXML itself is a third-party library that you can install using the pip tool just I like I did earlier with the requests library. So in the terminal window, I'm going to run pip3 install and then type lxml and you can see that I've already got it installed. But you can use the same method to install it if you need to. And just to make sure everything is fine, I'm gonna type pip3 list and then you can see the lxml library and I've got version 4.2.1 installed. So let's jump over to VS Code. Alright, here in my editor, I'm going to open the lxml_start file and you can see here I've imported the requests library and I've imported the ElementTree API from the lxml module. And in my main function, I already have the code needed to retrieve the XML content from the httpbin endpoint that provides XML. So just like with the dom in SAX…

Contents