A Beginner's Guide to Using XML Code

XML Has Many Uses

Reflection of male hacker coding working hackathon at laptop
Hero Images / Getty Images

Everyone seems to be talking about XML these days, if it's not Ajax, it's some other tool that uses XML as the back-end, but what are people actually using XML for? It's one thing to learn how to use XML, but what for? Here are some common uses for XML on the web right now:

  • web development
  • documentation
  • database development

XML in Web Development

In a way, you could argue that this is the most widespread use of XML, as XHTML.

Because XHTML is simply HTML 4.0 reworked, many HTML 4.0 sites are actually using an invalid form of XHTML.

But the benefit of XML is not that it already exists as XHTML, but that you can create web documents from XML using XSLT to transform your documents into HTML. You can then send your XML to an XSLT processor on the web server and serve that result to the web browser. This makes your documentation available in whatever format you need it to be in.

XML and Content Management

Ironically, with most websites that use XML, the web designers and content developers might not even know that XML is there. This is because there is generally a CMS or content management system that sits in front of the XML to make it easier for the content writers to write their web content without worrying about how to write HTML or design web pages.

XML and Documentation

Many companies are moving to XML to write their internal documentation.

The most common XML platform for this is DocBook. The advantage of XML for documentation is that it can be used to define the common traits in books, magazines, stories, advertisements, and so forth. And DocBook already has that type of information defined.

The best thing about XML for documentation is that the XML is easy to understand for humans, both of the actual documentation, but also the XML code surrounding it.

XML can be used for any type of documentation, from a publishing house to Marketing materials.

Here is an example of documentation written in XML:

  How to Write a Mail Link
    Jennifer Kyrnin, Web Design Guide
        Use a HTML tag to allow your readers to send email directly from your Web site.
      Write a link as usual email me
      Where you would normally put a URL, put the code "mailto" email me
      Then put your email address after the colon email me

As you can see, both the data and the XML are readable and understandable. The content is also in an order that would be expected by a human reading the document.

XML and Database Development

Databases are a natural use for XML because XML is all about data. Unlike XML for documentation, XML for databases does not need to be readable by humans. The data is simply written in such a way to allow machines to read it and make it accessible to a database.

Here's XML that might be loaded into a database:


Unlike the document XML, it's not necessary that this is easily readable by humans. Since it is meant to be input into a database, it is only important that it be processable by a computer.

XML is used by many companies for many different reasons. Here are some interesting uses:

mla apa chicago
Your Citation
Kyrnin, Jennifer. "A Beginner's Guide to Using XML Code." ThoughtCo, May. 26, 2017, thoughtco.com/who-uses-xml-3471378. Kyrnin, Jennifer. (2017, May 26). A Beginner's Guide to Using XML Code. Retrieved from https://www.thoughtco.com/who-uses-xml-3471378 Kyrnin, Jennifer. "A Beginner's Guide to Using XML Code." ThoughtCo. https://www.thoughtco.com/who-uses-xml-3471378 (accessed January 24, 2018).