Join Joe Marini for an in-depth discussion in this video Reviewing XML, part of Real-World XML.
Let's begin by taking a quick review of XML, what it is and what it looks like. Now if you haven't seen XML before or if you are new to the subject, then I suggest you take a look at another lynda.com title that's available in the Training Library called XML Essential Training and I do that title as well. It's really a foundational title. So if you are new to this and you haven't seen it before, I highly suggest you go check that title out first because that will provide the foundational knowledge that you will need to get through the rest of this title.
In this course, we'll be using concepts that are introduced in XML Essential Training. So you are going to want to make sure that you have those concepts and ideas under your belt before you tackle a title like this one. XML is the Extensible Mark-Up Language. It's tag-based like HTML is. So if you are familiar with HTML code, then XML will look very familiar to you. XML is used to describe data and the structure of that data. Because XML is extensible, you get to make your own tags up.
The benefits of XML are numerous. I have called out a few here. First, XML allows you to separate the content of a document from how it's presented. XML does not contain by itself any notion of how data should be presented to the person reading it or consuming it. You can also create tag sets that target specific problems. In fact, we'll take a look at how to do that in this course. XML stores information in a way that people can easily understand. So even though XML may be intended to be consumed by another computer system, or a machine, it's still in a format that a person can read and understand with some time and depending on how large the XML file is.
XML allows you to exchange data among disparate systems using technologies, for example, like web services. So two systems that may never have been designed to talk to each other can use XML to exchange data among them. Finally, XML is an open format and it's text based. So it can be processed by any program that happens to be aware of XML. Now that's not to say that XML doesn't have some drawbacks. XML, for example, is not good for storing large amounts of data.
In some cases, performance can also be slower than other methods of storing and retrieving data, so binary format, for example. If you were to store say a Photoshop file as an XML file, that file would probably be a lot less efficient than the binary format that you could store the image in. XML might not be the best format for representing certain kinds of data, audio, video, that kind of binary stuff. Finally, some parts of XML, like namespaces, are kind of difficult to understand and hard to work with. Now XML documents must be what's known as well-formed. They always have a single root tag, just like HTML does, and tags have to be properly nested.
In other words, you have to have an A tag completely inside of a B tag or to take an HTML example, you can't have a tag that's like bold and then italic and then close bold, and then close italic. The XML parser won't let you get away with that. Unlike regular HTML, empty tags always have to end with a slash inside the closing angle bracket, just like in XHTML for example. Attributes have to be inside quotes and they can't be minimized. If you are using XHTML, you're already familiar with these concepts. XML documents can be what's known as valid. In other words, you can take an XML document and validate it against a schema or Document Type Definition to make sure it confirms to certain rules. This is a sample XML file. In fact, we'll be using this sample XML file a couple of times in this course.
Now looking at the sample XML file, you can see that I have defined a few tags, like BusinessCard and name. So this is an XML file that represents the contact you might find on a business card. Here we have some phone numbers and an e-mail address. The phones have certain attributes. So you can see that XML can be used to mark-up tag sets that solve a particular type of problem. In this case, we needed a way to represent contact data on a business card. Later on in the course, we'll see how to do something like this in a real life web setting.
Okay, so that's a quick review of XML. Again, if you are new to all this, I highly encourage you to go check out the XML Essential Training title that's also available at lynda.com before continuing further.
XML Essential Training is a prerequisite for getting the most out of this course.
- Understanding the Sitemap index format
- Integrating XML and design
- Using XML effectively in Firefox and Internet Explorer
- Avoiding common design mistakes
- Understanding and implementing DOM algorithms
- Building an XML tag set
- Using XML with RSS and Atom
- Processing XML data with XSLT