XML was designed to solve two main purposes. To allow information to be stored and transported and to allow both humans and computers to read and modify the information.

Listen to the episode to learn more about how information was described and transferred before XML.

As for XML itself, let’s say you want to record a phone number in XML. You could start out with an opening tag called phone. The tag name is readable and clearly identifies the intent. It’s also surrounded by opening and closing angle brackets. You know, the less than and greater than symbols. After this opening tag and the brackets comes the actual phone number. The phone number can be formatted however you want. You could even include enough numbers to add a calling card if you want. There’s no need to worry about running out of a fixed and defined number of characters. Unless of course, that’s how you want it. It’s up to you. At the end of the phone number comes a closing tag that matches the opening tag’s name. This makes it really easy to spot where a phone number begins and where it ends.

Inside the opening tag, you can add what are called attributes. These are really nothing more than a name and a value. Maybe you could have an attribute called type and set its value to the string mobile.

Need another phone number? No problem, just start a new opening tag called phone, put any attributes that describe the phone number inside the opening tag, then put the phone number, and close it with a matching tag at the end.

And program that consumes XML doesn’t read fields located at specific starting and ending locations. Instead it looks for these tags. This means you can add new tags or even leave some out if they’re optional. You get to decide how to format your information and that format becomes part of the overall XML document.