Extensible Markup Language (XML): Definition & Explanation

Instructor: Lonny Meinecke

Lonny teaches psychology classes at King University, and has a bachelor's degree in IT and a doctorate in psychology.

In this lesson we will define what XML is, show you what XML looks like, and briefly share what XML can do for us. We will also look at examples of XML documents.

What's XML?

XML stands for Extensible Markup Language. Terrific, you say, so what's a markup language? Well, the most intuitive way you might look at it is like this: think of markup as the candy wrapper that tells you what's inside, and your content as the candy.

An XML wrapper is like wrapped saltwater taffy
wrapped taffy

The candy is your content, all that text and data you know has value, and you can't wait to share it. But candy needs to be wrapped in something, so people don't have to taste it first just to find out what it is. XML acts like a candy wrapper, allowing you to describe the candy quickly and in a very intuitive way. Now do you see? XML is anything which isn't candy: anything in a document which is not so much part of the document as it is about the document (annotations). In other words, XML is a way to describe and organize your content on places like the World Wide Web in a way anyone can follow in a standard way.

Where Does XML Come From, and What's it For?

XML comes from Standard Generalized Markup Language (SGML). As we just learned, it's a standard way to add additional text to a document (the wrapper) which can be distinguished from its real contents (the candy), and which adds to the usability of it. Technically, XML is a meta-markup language, which means anybody can create their own tags. (We'll talk about tags in the next section.) Why does that matter, you ask? Well, that means everybody can define how others will find and interpret their text or data, without everybody needing to know the details! Anyway, here are some great things about XML:

  • It's great because both people and machines can read the same document
  • It's a simple yet extensible means to store and organize data (extensible = anyone can extend it)
  • It lets you store and share data, yet it leaves you free to display it any way you like
  • It's an open standard, which means it isn't going away soon
  • Theoretically, you can store any kind of data in an XML document

What Does XML Look Like?

In its simplest form, XML markup consists of wrappers that have unique names. You can call them anything you like. Just put your clever keyword or tag between some angle brackets and there you go! Now make a copy of that, but put a forward slash just before the tag name to indicate the end of the wrapped content, like so:

Simple XML wrapper example
1st xml example

Anything you put between those (your candy) will become associated and discoverable using the keyword tag. And you can make up just about any meaningful label for the tag you wish. Like I said, think of markup as the candy wrapper that tells you what's inside, and your content as the candy. Let's take a look:

Wrapping content with XML
2nd xml example

As you can see, the opening and closing tags are the same except for the forward slash. Between those, we have a bit of text, in this case. Tags mark the start and end of elements. An element in XML is the basic building block. But that's not all: a powerful (but optional) part of an element is called an attribute. That's a property of the element which you can reliably expect to find. Let's look at another example.

Let's say my cat Mimi has 3 names (based on T. S. Eliot's difficult matter of naming cats). One is his common (sensible) name. And he has a fancy name for special occasions too. But he also has an inscrutable name (one he never can tell; only cats know that name).

An XML element example with an attribute
xml with attribute

Here you can see the overall wrapper or tag (pet) marks off our element; it has one attribute (species) that goes along with it. Then we have wrapped 3 elements inside of it (each of Mimi's 3 names).

What's an XML Document?

As you might guess, XML isn't just a bunch of wrappers shared willy-nilly on the Web. We generally find candy in bags, don't we? Even if it's individually wrapped, all that candy is just so much easier to work with when contained. Well, XML has bags, too! We call those XML documents.

An XML document is almost like a bag of wrapped candy
bag of taffy

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account