"The Extensible Markup Language (XML) is a general-purpose specification for creating custom markup languages. It is classified as an extensible language because it allows its users to define their own elements. Its primary purpose is to facilitate the sharing of structured data across different information systems, particularly via the Internet, and it is used both to encode documents and to serialize data. In the latter context, it is comparable with other text-based serialization languages such as JSON and YAML..."
By now your eyes are probably glazing over and you’re wishing you’d never even HEARD of XML.
Well, don't panic, because it’s really not as complicated as you think!
XML is, quite simply, a way to store information. The beauty of XML is that it's completely customizable by YOU, the web developer. There's no fussy code to learn or debug, since you can use whatever names you like for the fields. It's actually the easiest programming language to learn because you define most of the code yourself.
OK, let's look at an example. Suppose you wanted to create a catalog of your favorite books. Using XML, your entries would look something like this:
<comments>My favorite book!</comments>
As with HTML, the text between the < > symbols is called a 'tag.' The difference in XML is that you, the web developer, can define your own tags and call them whatever you like. There are a few syntax rules to learn before you start building your own tags:
- Every opening tag must have a matching closing tag. In other words, if you have the tag <book> in your XML document you must have the closing tag </book> somewhere further down.
- Unlike HTML, tags in XML are case-sensitive. That means
- A few characters have pre-defined meanings and can't be used within a tag. They are: less-than symbol (<), greater-than symbol (>), ampersand (&), apostrophe (') and quotation mark (").
Perhaps the biggest advantage to using XML is that its documents are stored on your computer in plain text format. As a result, any computer, browser or server can understand these files regardless of type, so you can easily share data with your visitors. XML files can be used with almost any computer application. It's also easy to call XML files from an HTML page, meaning that you don’t need to worry about redoing HTML every time you add more data – the only thing you need to adjust is the XML document.
Stay tuned for our next article, in which we’ll break down the elements of an XML file and help you build your first XML document.