Hello, and welcome to Python for Everybody. I'm Charles Severance, I'm the author of the textbook, and we're going to do a little bit of code. If you want to get your hands on the code, go to the materials website, materials.php, it's actually materials.php, and download the sample code. The code that we're going to work on today is the XML code, and we need to be able to talk XML, to work with web services. So, here's one of the examples from the book, it's xmlone.py. So, later we'll be pulling XML, and Jason from the web, but for now we're going to put it in a triple-quoted string, so data, and we're going to use a built-in XML parser in Python called ElementTree. When we say import XML etree, Element Tree as ET, this as ET gives us basically a shortcut handle for it. So, the idea, this is a string that has less sense, and greater thans. It looks like structured information, and it is, but really at this point, it's only a string. Now, we have to call this ET from string, to read this, and give us back a tree object, and what it does is this might blow up. This code might blow up right here, if there was a mistake in it. Matter of fact, I can probably put a mistake, and let's see if I can delete this, and save it, and run this code, and we'll see that it will blow up, right? So, it blew up here in line A, ElementTree blew up, I mean it it blew up in line 12 of the code, which is right here, this failed because the line eight of the XML string was wrong. So, let's put the slide that back in. So, now it's properly formed XML. So, this tree, we get back, I name it tree just because I always name it tree, but you could name it X. So, the key is as tree.find goes, and looks for a tag name, find in it, tree is no longer got less thans, and greater thans in it, and turn these into objects within objects within objects. So, tree find name says, "I would like to find the tag name," and that's what this bit is right here, and then.text.text is going within that, and grabbing that text. If we say treefind.email, then that's going to give us this, and then that object, and then.get asks for the contents of the hide attribute, which is the string, yes. So, if we run this, now that it's fixed, python3 xml1.py, it will pull in, and get the at the name, and the attributes. So, it pulled the checkout, and so you get this object, and then you dive into that object. So, that's xml1.py. If you've got a tag, you can either get the text out of the tag or you can get an attribute out of a tag. So, now, let's take a look at xml2.py. Again, we import ElementTree, and we have a tag, and there's XML's always got to have a single outer tag. But, this time we're going to have an effect a list. Now, let's line this up a little better. There we go. That looks a little prettier. So, the fact that as users doesn't mean anything, but we often come up with semantically meaningful names for these things. Users is going to have it as a children, a list of user tags. So, the children under user, user under user, and then this has each of these as a tag. So, we want to parse this, and this is a common thing we want to do. So, again, the first thing we do is we read the string to just take this. It's a triple-quoted string going from here to here. Then, we're going to instead of doing fine, which gives us one tag, we're going to find all, the users tag, the user tag, that is a child of users, and we get back a Python list of the tags, not of the texts, but of the tags. So, there's a one tag, and there is another tag. So, you do len of that, so we can see that we got two. Then, we can write a four loop, and this item is going to iterate through the tags that are the user tags, that are children of users. So, the first time item is going to be this tag, a tag, remember. Then, the second time, it's going to be this tag. So, we can do things like find and get, just like we did with in xml1. So, running this is not too exciting, python3 xml2.py. You see that there are two users that comes from this print right here. There are two users in there, and the first one, if we go into name, and we go find the text within the name tag, within user, then we get chuck, and then we get the ID, which is 001, we find the ID within that item, and then we get the text, and then we look, and we grab the X attribute off of that. So, we see chuck 001 and two. Then, in the next tag, we get the four loop continues, and we print that out. So, that's just a basic run-through of the XML from the chapter in the Python book. Okay. Thanks.