 Hey everybody, this is Brian. Welcome to the 93rd Qt Tutorial with C++ Enquiry Programming. We're not actually going to be doing any programming today. So, if you already know XML, feel free to skip this video. If XML is new to you, then feel free to watch the video. This is the primer for XML. First off, what is XML? If you go out to Wikipedia and look it up, XML stands for Extensible Markup Language aka XML. The set of rules are encoding for documents, machine, blah blah blah. You can read this whole thing, but really what it boils down to is XML is a structure that defines data. Where have we seen this before? It looks awfully familiar. If you look at this graphic, what does that look like? Well, if you right click the web page, go View Source, looks awfully familiar to HTML, doesn't it? That's because they both backbone off of a similar language, which we won't discuss. But basically, what you need to understand, it's very simple. XML is just plain text, very similar to HTML. With XML though, you have a set of rules. And as everything, it seems kind of simple at first and the deeper you get, the more infinitely complex it becomes. But what you need to understand the most is XML is plain text. It's a set of rules or behaviors that you should follow. You need to understand some key terminology and you need to know basically how things are marked up. For example, you have tags. It starts with these brackets and then intags, which is a brackets with a slash. See that slash right there? Just like HTML if you know HTML. Or you can have an empty element, which is of course ends with a slash. So like line break would be an empty element. Where section, there's the beginning, there's the end, that's the data in between. Very simple, very easy to understand. Here's a declaration. The declaration says like the version, the encoding, you know, text can have different encoding. You can have escape characters, you can have invalid characters, things like that. All you really need to understand when working with XML when you first start off is the basics of how to use it. For that, I recommend going out to w3schools.com. No, I don't get any sort of kickback for mentioning their names. I just really like their website and they have some awesome tutorials on just about everything web. And you see right on the top here you have XML and here is an example of an XML document. Now this is a simple document, but it's got some complex things going on here. There is the declaration. Notice how it's got that question mark? It says it's XML version 1.0. And then we've got this note in note. Well that is an element. And that whole thing right there is one element. And it's got elements inside of it. So an element can have an element in an element in an element. You just go on and on and on and on. So inside of note, whoops, we have 2. And from, heading, body. Now each one of these elements can have what's called attributes. For example, let's go into the source of this document here. But we can find some attributes really quick. Yes, we can't like this meta tag right here. That name is an attribute. The tag is the meta tag. This whole big long thing that goes off the string. But the attribute is name. Yeah, it's name. And then it has the word description, then content, et cetera, et cetera, et cetera. This would be a better example right here. Because you can see the entire tag. HTTP, equiv, and then content. Those are both attributes. Now XML, you can also define what's called a schema. And it really goes beyond the scope of what you need to know to really work with XML. But a schema defines how the data should work. So go out to W3Schools.com and just kind of go out here and browse around and see some of the things they have and how things are structured and get some basic understanding of how XML is structured. See how you can have a root, a child, a sub-child. That's one thing you should understand about XML is that you need to have a root element and you can have only one root element. So what you would say is root and then you'd have your children. You can have as many children as you want. And each child can have as many sub-childs and sub-sub-childs and sub-sub-sub-sub-childs, et cetera, et cetera. I don't think there's even a word as sub-sub-sub-child. But anyways, you get the point. Now, what would you use XML for? XML is perfect for, you guessed it, moving data back and forth. You'd use XML for things like SOAP, simple object access protocol. Things of that nature. You move data around for whatever you could imagine. For example, bank transfers. Let's say you've got two systems. Let's say you want to transfer money from Bank of America to Independent Bank. And I don't bank at either one of those, but those are just examples. They have two different systems. Their internal software is different. Their IT departments are different. Everything about them is different. But they want to move the data between the two systems. XML would be perfect for that. There's a whole, you know, spawn generation of companies out there that do middleware. But you would define it in XML. So company A would create the document, send it to company B who would read the document. And because it is using XML and they've already defined a schema and everything behind it, they know exactly how it's going to be formatted. Now, one thing you should know is there are companies out there like Microsoft, which some people love Microsoft. Some people hate them. I'm not going to give you my opinion. But they obviously put their spin on everything. So there's not just XML. There's MSXML. So you got to be aware of the different little flavors of that. And I think they've actually tried to be backwards compatible with XML. But like everything with Microsoft technology, you know, you got to watch out for the little gotchas or little gremlins as I like to call them. So go out to w3schools.com, kind of look around, see, you know, what XML is used for, how you use XML, how it's structured, get kind of a feeling for it, like here's a nifty little XML document. And you can see how you've got like an encoding with an ISO, et cetera, et cetera. That's part of the tag. And then you're just saying NIFT and then head, body, headlines, et cetera, et cetera. It's an example of a weather service here we got. I mean, this is just some small examples of what XML can be used for. If it looks big, scary and intimidating, don't worry, it's actually very easy to work with. And over the next couple of tutorials, we're going to be working with XML. And I wanted to break this up into a couple of tutorials because people tend to get kind of confused or the whole deer in headlights about XML because it looks daunting and complex and you get the Uber nerds out in forums that are going, oh, no, you can't have it like this. It's got to be like that. And then it boo boo and, you know, just tell those guys to go away. XML is designed by nature to be flexible. So, flex it. Anyways, this is Brian. I probably talked way too much on this tutorial. Go out, do some research on XML, get comfortable with just looking at it and how it feels and how it acts. Next couple of tutorials, I hope to knock those out the next day or two. We're going to write XML and we're going to read XML. So, thanks for watching. I hope you found this educational and entertaining.