HTML Programming Technology Explained Web Development XML

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


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.



Source link