What Is an XML File and How Can You Open and Use It?
Whatsapp Pinterest
Advertisement

XML stands for eXtensible Markup Language. Its purpose is to describe and structure data on the internet, for mobile apps, and elsewhere. Are you wondering how this works and what XML is used for? Let us help you understand the details.

What Are Markup Languages?

Markup languages annotate text or add additional information. These annotations remain invisible to the end-user. The “machine”, such as your browser, reads these annotations before processing and presenting the text as instructed by the markup commands.

According to Wikipedia:

“The idea and terminology evolved from the ‘marking up’ of paper manuscripts, i.e. the revision instructions by editors, traditionally written with a blue pencil on authors’ manuscripts. In digital media, this ‘blue pencil instruction text’ was replaced by tags, which indicate what the parts of the document are, rather than details of how they might be shown on some display.”

A well-known example of a markup language is HTML (HyperText Markup Language) The Essential HTML FAQ You Should Bookmark The Essential HTML FAQ You Should Bookmark HTML has been around for a while, so it's about time you learned the basics. Here's what is it, how it works, and how you can write some common elements in HTML today! Read More . While HTML (and other programming languages) define the look of a website, you should never see a trace of the code. What you do see is its interpretation by your browser. For example, font formatting or embedded images.

How Does XML Work?

XML is a meta markup language developed for the internet. It’s a simplification of SGML (Standard Generalized Markup Language), the mother of all markup languages. XML is extensible because users can add and define new tags or building blocks. By adding building blocks, users can adapt XML to their needs.

To explain how this all works, let me take a bit of detour, using HTML and CSS as examples.

How XML Relates to HTML

XML is similar to HTML, but because users can add their own building blocks, it allows for more flexibility. A key difference between HTML and XML is that HTML defines how data looks, while XML defines what data is. That’s why XML cannot replace HTML, rather it extends it.

To describe data, XML relies on Document Type Definition (DTD). You could say that this is the machine’s dictionary. It allows the machine to understand the markup language. Thus, each document must start by defining the type of DTD to be used. HTML uses the same principle. The code you’ll find on many websites could look something like this:

<!doctype html public "-//w3c//DTD html 4.0//en">

This specific example tells your browser that the DTD is html 4.0 in English. The browser can then go ahead and compare each of the given commands to its DTD, which tells it what to do with each command. That’s how the command <b> translates to bold text or <u> to underlined text.

Doctype HTML XML document
Image Credit: photovibes1/Depositphotos

How CSS Solves an Issue With HTML

The problem with HTML is that it consists of a static set of commands. Whenever you want to define certain attributions, you need to type these commands. Over and over again. While this makes HTML straightforward and easy to learn, it also limits its flexibility.

For example, say you want to change the size or color of a header that you have used a dozen times throughout your website. Imagine you had to change the attribute of each of the one dozen headers individually. How boring!

In web design, Cascading Style Sheets (CSS) have eliminated this tiresome editing of HTML documents. Now, you simply add the attribute “H1” to your header on the website and in the style sheet you define what an “H1” header looks like. And when you want to change the look of that header, you only change it in one place, i.e. the style sheet. Problem solved.

Thinking of starting your own website? MakeUseOf readers can get special discounts if they sign up for InMotion Hosting using this link or Bluehost using this link.

How XML Handles Data

XML structures and defines data. It doesn’t bother with specific attributes, like size or color. Its building blocks are similar to HTML tags that relate to a CSS. It plainly defines the title, headers, text, and other elements of the document and leaves the interpretation to the machine.

For a much more thorough explanation, I recommend this introduction to XML.

What Is XML Used For?

XML has found wide application. Today, various programs and devices use it to handle, structure, store, transmit, and display data. For example, it’s widely used in B2B data exchanges. XML is also the standard for Office file formats, including Microsoft Office and Google Docs files.

Rather than integrating data into an HTML document, it outsources it to separate XML files. Since XML stores data in plain text format, the storage is independent of your platform and your data can be exported, imported, or simply moved much more easily.

Many other languages are based on XML, including XHTML, WAP for handheld devices, or RSS for feeds. For example, as a commenter pointed out, if you add /feed to the end of the URL of this article you’re reading, you’ll see the XML RSS code of this article: click here to see.

How to Open an XML File

As mentioned above, XML stores data in plain text. That’s why you can open XML files with a number of different programs. Generally, right-click the XML file, select Open with from the menu, and choose a program. You can try any of the programs below:

  • Windows Notepad or any other text editor
  • Notepad++
  • Any web browser

You can also try an online XML viewer like the one from Code Beautify.

You’ll be able to read the file with any of the programs above, but Notepad++ and dedicated XML viewers or editors will color code XML tags and thus make it much easier to grasp the structure of the data. Note, however, that these programs cannot execute XML because all you can find inside the document is structured data.

The XML Format Demystified

XML isn’t the internet staple it used to be. Today, JSON is its most popular alternative to integrate data.

If you’re a programmer, however, you’ll still have to work with XML occasionally How to Read and Write XML Files With Code How to Read and Write XML Files With Code Although the popularity of XML has waned recently, you may run into it occasionally so it's important to learn how to read and write an XML file from code. Read More .

Explore more about: HTML, Programming, Web Development, XML.

Enjoyed this article? Stay informed by joining our newsletter!

Enter your Email

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Nick
    February 2, 2017 at 6:23 pm

    Thanks for your wonderful article on XML, it really helped me but just one question if XML just structures, stores and transports data, what is the use of it? I mean isn't there a more easier way of transferring data?

  2. Punit
    July 14, 2016 at 10:08 am

    super easy to understand article. thanks. i just wanted to know overall review, that saves a lot of time for me thanks. :)

    • Tina Sieber
      July 14, 2016 at 6:26 pm

      Very welcome, Punit and thank you for the feedback!

  3. Blopez
    June 8, 2016 at 2:16 am

    So this decides where my info is sent basically??

  4. khushi
    January 6, 2016 at 6:04 am

    m happy to get to know what is XMl.

  5. khushi
    January 6, 2016 at 6:03 am

    Your artical is the best ever on this topic :)

  6. khushi
    January 6, 2016 at 6:02 am

    try to understand friends.what this article says!it says everything !!!now m going to start learning ,using,fun with XML............................................................>>>>

  7. khushi
    January 6, 2016 at 5:58 am

    i wanted to know that is xml basically and i did watch 3-4 for videos and many official website.but they fail to clear me what is it...thank you so much!!!!!!!!!!! you did a great job for me....thank again for clarifying me that it is noting only a external source with and data with tags so that we can retrieve it...
    it;s is similar to adding a ntepad file in over game,app etc..hurreeeyyyy!!!!!!!!!!!!

    • Tina Sieber
      January 26, 2016 at 10:11 am

      Thank you for your comments, khushi! It's great to hear that this old article is still useful for people. :)

  8. zmanww
    August 12, 2010 at 1:41 pm

    I work with all different types of XML files on a daily basis, and this article just completely confused me.This one sentence in peticular:

    "An XML document basically is a type of style sheet that defines how its subordinate documents are to be read by the ‘machine’."

    Not saying it's wrong, but that seems like the complete opposite of what XML is. It seems like your getting XML and XSL confused.

    Most XML (that I know of) is used like a properties file, or to send data between things like clients and servers.

    If you wanted to explain what XML was you should have included what some examples actually look like. The simplest comparison that most people would understand would be RSS feeds.... Just open a RSS feed in your browser, then view the source, That's XML (in one form).

  9. Tony
    August 11, 2010 at 1:41 am

    An excellent post to understand XML in an easy way.

    • Tina
      August 11, 2010 at 4:39 am

      Thanks for the feedback Tony!

  10. Dammit
    August 11, 2010 at 1:03 am

    @Vordreller

    The Access XML export function suggests that such is the case - at lease part of the case.

  11. Vordreller
    August 10, 2010 at 8:17 pm

    So, would it be far fetched to claim that an XML file is clear-text database? Or that it can be used for such purposes?

    • Tina
      August 11, 2010 at 4:39 am

      I think you're confusing clear text (not encrypted) and plain text (not formatted / no code). If you mean plain text you're right. Although, since the data is also not encrypted, clear text isn't wrong, either.

      The XML defines how to read data stored in plain text documents. So you have a database of plain text files, with the XML translating to the 'machine' what it all means.