What Is XML?
XML stands for Extensible Markup Language. XML was created by the World Wide Web Consortium (W3C) as a markup language used to define a syntax for encoding documents that different “reading machines” (including humans and computers) could read. In fact, XML files are just plain text files that utilize custom tags to describe different features of the document, including its structure and how the document should be stored, shared, and transported.
Let’s briefly compare XML to another markup language that you are likely already familiar with – HTML (Hypertext Markup Language). HTML is used to encode web content. It has a pre-defined set of markup symbols (or shortcodes) to describe the format of the content of a web page. The example below shows a very simple HTML code that uses pre-defined tags to make certain words bold and other italics:
This is the way to make bold text and this is the way to make italic text One of the most notable differences between HTML and XML is that XML is extensible, and it does not have a predefined set of markup symbols. Users are free to create their own set of markup symbols. It is therefore possible to build an unlimited and self-defining markup language used to describe the content.
In other words, HTML is a markup language used to describe how data is presented, while XML is a dedicated language used to describe and store content.
XML is very frequently used as the basis for hundreds of other document formats. Microsoft.NET utilizes XML for its configuration files. Microsoft Office uses XML as the basis for document structure (that is what the “X” stands for in the .docx, .xlsx, and .pptx document formats).
How Do I Open an XML File?
There are several ways to open an XML file directly. Keep reading to find out how to open and edit XML files with any text editor, view them with any web browser, and view, edit, and even convert them to other formats using a website.
Opening and Editing an XML File Using a Text Editor
As we have already said, XML files are just text files. This means you can open them using any text editor. However, many text editors, such as Notepad, are not designed to display XML files with their proper structure. While it might be enough to just take a quick look at an XML file to find out what it is, there are better tools you can use.
Right-click the XML file you wish to open, hover over “Open with” on the context menu, and select the “Notepad” option.
The file will open, but it will lose most of its formatting everything will be jammed together. So, it is more practical to use a more advanced tool like Notepad++, which is designed to present syntax and formatting the way it’s meant to be.
Note: Regardless of which operating system you use, try to find an appropriate text editor that supports XML files.
Viewing the Structured Data Using a Web Browser
If the only thing you need to do is to just view an XML file, any browser will do the job. Actually, it is likely that your default web browser is already established as the default XML file viewer. So just double-click the XML file you want to view, and it should open in your browser. In case that does not happen, right-click the file, go to “Open with” and click on the browser you want to use.
When the file opens, you will see well-structured data. It’s not color-coded and as good-looking as the view you get using Notepad++, but it is way better than the view you get with Notepad.
Viewing, Editing, and Converting an XML File Using an Online Editor
The good news is that if you only occasionally need to edit or convert an XML file, you don’t have to pay for or even download any editors. There are some pretty good online XML editors available online for free. Among those are TutorialsPoint.com, XMLGrid.net, and CodeBeautify.org. They all allow you to edit, download and even convert the file you’re working with to a different format.
Let me walk you through an example using CodeBeauty.org. You’ll see that the page is separated into three sections. The section on the left shows the XML file you are working with. The middle section is for different options. And on the right are the results of the changes you make.
Let’s have a look at the main options available to use:
- The “Browse” button enables you to find and upload the XML file. You can upload it from your computer or use the “Load URL” button to get the file from an online source.
- The “Tree View” button allows you to see the data displayed in a well-formatted tree structure. All the tags appear on the left and are orange and the attributes are placed to the right of the tags.
- The “Beautify” option shows the data in neat-looking, easy-to-read lines.
- The “Minify” option shows your data minimizing the amount of white space as much as possible. It tries to display each piece of data on one line. This option is useful when you attempt to make the file smaller. It makes the file more difficult to read, though.
- The “XML to JSON” option allows you to convert the file from the XML to JSON format.
- The “Export to CSV” option enables you to save the data as a comma-separated values file.
- The Download” option allows you to download any changes you have made.