The Complete XML Guide: Definition, Examples, and How to Open a File

If you’re learning coding , you’ve probably heard of XML. Or maybe you’ve come across files with this extension without knowing what they do. So, what exactly is XML?

In short, XML can help you understand the basic structure of a document or web page . If you are familiar with HTML , you might think that they are the same. But actually both have different functions, you know!

Curious? Well, this article will explain the basics of XML. Starting from the understanding. for example, the difference with HTML, to how to open the file.

Let’s get started!

Table of contents close

1 What is XML and Its Benefits?

2 What is the Difference between XML and HTML?

3 Example of XML Structure

4 How to Open an XML File?

4.1 1. Using Notepad

4.2 2. Using the browser

4.3 3. Opening the Online XML Editor

5 Ready to Use XML?

What is XML and its Benefits?

Extensible Markup Language (XML) is a markup language created by the World Wide Web (W3C) consortium . This language serves to simplify the process of storing and sending data between servers .

So, why does the process of storing and sending data between servers need to be simplified?

This is because each server can have a different system. Thus, data exchange between servers whose systems do not match will take a lot of time.

You need to change the data format to match the destination server. Changed data is also at risk of being lost.

As a workaround, XML stores data in a simple text format. So you don’t need to change the data format at all. Even the data format will remain the same even if it is transferred to another server.

Therefore, XML is also easy to update to a new operating system or a new browser. The language is also easy to read by humans, computers, to voice recognition technology.

What is the difference between XML and HTML?

As explained above, the main function of XML is to store and transmit data . Meanwhile, the main function of HTML is to display data .

In addition, you can use any tag in XML. Another case with HTML, which requires special tags ( predefined tags ) to carry out its function.

To see the difference between XML and HTML more clearly, let’s look at how they both describe the same content.

First of all, here’s how HTML displays data:

<body> <h1> List of PT.A Products </h1> <h2> First Products </h2> <p> The first products can help increase endurance </p> <p> <b> Price: Rp. 20,000 </b> </p> <p> <b> Shipping: Rp. 5000 </b> </p> </body>

 

 

 

 

 

As you can see, HTML uses special tags like <h1> , <h2> , or <p> to define the structure of its content.

Apart from that, you can also see how the data will be displayed. For example, in the price and postage section, there is a <b> tag that makes the data appear in bold .

Now, let’s take a look at an overview of the contents of the XML file:

<productlisting title : ” List of Products PT . A ” > <product> <name> First Product </name> <description> The first product increases endurance </description> <price> Rp. 20,000 </harga> <ongkir> Rp. 5000 </ongkir> </product> </productlisting>

 

 

 

 

 

 

So, you can see the content of the tag. Examples include <name> , <description> , and <price>. It also shows that you are free to specify any tags.

However, none of the tags associated with the display content.

To make it easier to understand, here is an XML to HTML comparison table:

XML HTML
Serves to store and transmit data. Serves to display data.
Free to use tags that you create yourself. Must use certain tags to carry out its function.
Can distinguish capital letters from lowercase letters ( case sensitive ). Cannot distinguish capital letters from lowercase letters ( case insensitive ).
Consists of structural data. Does not consist of structural data.
It should have a closing tag on it. No need to use a closing tag.

Also read: What is HTML5? Check out the differences between HTML and HTML5 here!

Example of XML Structure

The structure is quite simple, because it only consists of three segments, namely:

  1. Declaration– This section identifies the XML version in use.
  2. Attributes– This section contains a description of the object. Examples such as name, title, title, or the like.
  3. Element– This section contains tags that describe objects. The structure consists of three parts, namely the opening tag, content and closing tags.

The following is an illustration of the use of the three:

< ? xml version = “1.0” ? > -> Declaration <productlisting title : ” List of Products PT . A ” > -> Attribute <product> <Name> First Product </name> -> Element <description> The first product increases endurance </description> <price> Rp. 20,000 </harga> <ongkir> Rp. 5000 </ongkir> </product> </productlisting>

 

 

 

 

 

 

 

As you can see, the declaration indicates that the version being used is 1.0 . Then, the attributes used in the product listing data are the PT. A .

The data above consists of several elements, namely name, description, price, and postage . And each element consists of three parts. For example <name> (opening tag), First Product (content), and </name> (closing tag).

How Do I Open an XML File?

Okay, now you know what xml is and what the files look like. But how do you open the file?

Maybe you’ve tried opening it, and then saw this message:

Relax, how to open it is easy. There are several ways you can use:

  1. Using Notepad

This method is very simple. You only have to do three steps:

  1. Right click on the XML file.
  2. Click Open with.
  3. Select

If you feel that Notepad is too simple, you can use Notepad ++ . This application can present the contents of the file with a neater appearance.

Its use is more or less the same as regular Notepad. You just need to right-click the file, then select edit with Notepad ++ .

  1. Make use of the browser

Apart from Notepad, you can also open XML files through any browser on your device. Like Chrome , Firefox , to Internet Explorer . Here’s how:

  1. Right click on the file.
  2. Click Open with.
  3. Select the browser. If it’s not on the list, you can click Choose Another App.
  4. If it’s still not there, click Look for another app on this PC.
  5. Locate your browser’s .exefile , then click Open .
  6. The file will open automatically in your browser. Here is an example of how it looks on Google Chrome:
  7. Open the Online XML Editor

Another tool you can use to view the contents of an XML file is an online XML editor such as CodeBeautify . For example, here’s how to open an XML file with CodeBeautify:

  1. In the main XML ViewerCodeBeautify page, click the Browse button .
  2. Select the file you want to open, then click Open.
  3. Wait for the loading process for a while, then you will see the contents of the file.

Ready to use XML?

XML is a markup language that functions to simplify the process of storing and sending data between servers. Unlike HTML, whose main function is to display data.

In this article, you have learned what they are, examples of their structure, how to open files, and how they differ from HTML.

 

Leave a Comment

Scroll to Top