XML
Tags: xml, html, semantic, sgml
Published: 2019-02-28 01:21:07

---
title: XML
description: What is XML? Why do we use it?
date: '2019-02-28T01:21:07.951Z'
---
<i>Originally published on Medium - 02-28-2019</i>

What is XML? Why do we use it?

Extensible Markup Language (XML) is an all-purpose tool for creating your own markup language. By defining a set of rules, and giving your language an applicable style sheet, you can define your own markup that is specialized to your business, or application needs. While most of us are familiar with HTML, XML differs in that it allows you to build a markup language. XML is pervasive, with applications in business, banking, and healthcare industries. As a non-proprietary open source language, XML combines the ability to be used as a powerful form of data transfer with flexibility and ease of use.

Most of us are familiar with HTML and its applications, but how do the two differ?

HTML and XML are both children of their parent language SGML

They’re CHILDREN. Get it?!

Where SGML is robust but complex, and HTML is inflexible in its already defined structure, XML bridges the gap combining elements from both to create a responsive and flexible way to structure data. Users cannot create new tags or define how they should be displayed in the browser in HTML, while they can in SGML or XML. XML is able to explicitly define new tags, and provide a middle-ground between HTML and SGML documents.

<h2>Creating An XML Markup Language — XML Components</h2>

<h3>Declaration</h3>

To create a language first you must create your declaration. Much like the first line in an HTML document, an XML declaration includes information that defines attributes of the document.

You must include a version and encoding, but the standalone declaration is only if you want to ignore the standard rules provided by the DTD (Document Type Definition). The DTD is the group of markup declarations for SGML-family languages.

<h3>Tags and Elements</h3>

Tags are self-descriptive and define the types of elements that exist within your XML file. Elements in an XML language are the building blocks of the XML file. They contain one root element and may contain nested elements.

<h3>Attributes</h3>

Attributes provide additional information about elements, they are name-value pairs with single or double quotes. Attribute names must be unique.

<h3>Comments</h3>

Comments provide additional information about the document but are ultimately not parsed.

<h3>Schemas</h3>

Schemas describe the structure and content of an XML document. They create a common vocabulary for all documents of a particular XML language. You can create your own schema by using the DTD or creating your own XML schema. WW3 has some resources to get you started!

<h3>Advantages and Final Thoughts</h3>

XML allows a developer to create their own semantic data structure, set up rules governing the data, and use the data throughout their applications. A markup language that is unique and serves the needs of an application can make code clearer and more explicit. Entire industries have built their own XML languages some of which include EPUB, RSS, SVG, and MathML. XML was even the most popular data interchange format until JSON was established. Give it a try and see if you can build your own language!