●XML stands for Extensible Markup Language that is similar to html. The whole idea behind creation of XML file format was to store and transport data without being dependent on software or hardware tools. The “X” in XML is for extensible which implies that the language can be extended to any number of symbols as per user requirements. It is for these features that many standard file formats make use of it such as Microsoft Open XML, LibreOffice OpenDocument,XHTML and SVG.

●XML, short for eXtensible Markup Language, is a set of tags and codes that help carry the data presented on the website. . The main objective of XML design is to ensure simplicity and compatibility.

XML File Format 

XML is a flexible data format. It can store an array of different data types, such as numbers, strings and executable code. XML’s flexibility makes it a popular choice for data storage and transmission in web applications.

XML Syntax

Let us now look at the XML syntax and declaration.

The following is the basic XML syntax – 

<?xml version = “1.0” encoding = “UTF-8” ?

<root>

    <child>

        <subchild>…..</subchild>

    </child>

</root>

XML Declaration 

The following code shows the syntax for XML declaration 

<?xml version=”version_number,” encoding=”character_encoding” standalone=”yes_or_no” ?>

XML Comments 

Comments are optional. Adding comments to a document can help you comprehend it better. 

<?xml version=”1.0″ encoding=”utf-8″?> <!– This is XML Declaration–>

XML Tags and Elements 

Except for declarations, tags work in pairs. An opening tag and a closing tag make up each tag pair 

<> is used to enclose tag names. The start and end tags for a tag pair must be identical, except that the end tag must have / after the <.

<employee>

        <firstname>John</firstname>

        <lastname>Doe</lastname>

        <title>Engineer</title>

        <division>Materials</division>

</employee>

In the above example, employee, firstname, lastname, title and division are tags. Tag names are also referred to as elements.

XML Attributes 

In the start tag, the attribute for an element is inserted after the tag name. For a single element, you can add many attributes with distinct names. 

There are two main rules to define an attribute – 

  • Attribute values must be within quotes.
  • An element cannot contain several attributes with the same name.

Consider the same example as above 

<employee id=”be129″>

        <firstname>John</firstname>

        <lastname>Doe</lastname>

        <title>Engineer</title>

        <division>Materials</division>

</employee>

Here the “id” is an attribute specific to that employee. 

The benefits of the XML

  • lightweight to transmit over the internet
  • easy for humans to read
  • understandable by computers

What Is XML Used For?

XML (eXtensible Markup Language) is used to store, transport and exchange data between applications, platforms and organizations. It is often used to describe the structure of data in a way that can be easily understood by both humans and machines.

What Is an XML File?

An XML file is a plain text file that contains data marked up using XML syntax. The data in an XML file is organized using tags and attributes, and can be read by a variety of applications and platforms.

HOW TO OPEN AN XML FILE

XML files can be opened and viewed using any text editor, such as Notepad or Sublime Text. You can also open and view an XML file in a web browser, although the format of the file may appear differently in different browsers.

XML Alternatives and Siblings

XML is by no means the only data format we can use to transfer data online. As a matter of fact, JSON is the most well-known and widely used data format for this purpose.

Here are some alternative data formats that are similar to XML:

  1. HTML(Hypertext Markup Language): HTML is a markup language that powers most modern-day websites. HTML isn’t used to transmit data online. The way we write HTML is very similar to XML as both HTML and XML use tags in a structured manner.
  2. JSON (JavaScript Object Notation): JSON is a text-based format similar to XML. Unlike XML, JSON doesn’t use tags in labeling the data. JSON is the most popular data format when it comes to transmitting data over the internet.
  3. YAML (YAML Ain’t Markup Language): YAML is a human-readable data serialization format. YAML is both easy to read and write. It is reminiscent of XML or JSON but serves a different purpose. Unlike XML, YAML is used in configuration files for configuring parameters and initial settings in the software.

XML VS. HTML: WHAT’S THE DIFFERENCE?

  • XML is a markup language used to store, transport and exchange data.HTML is a markup language used to create web pages.
  • XML focuses on storing data. HTML displays data.
  • XML uses tags to describe the data, but the tags are defined by the user. HTML has predefined tags.

HTML vs XML

Although HTML and XML are markup languages, they have significant differences. Here’s a list of the differences. 

HTML XML
HTML is a markup language that focuses on how data appears.XML is to transport and store data. It focuses on what the data is
HTML is a markup language in its own right.XML is a standard for defining markup languages.
Format driven Content Driven 
HTML is not case sensitiveXML is case sensitive
HTML has predefined tags of its own.Tags can be defined as needed.
Because HTML is used to present data, it is static.Because XML is used to send data, it is dynamic.
HTML does not preserve whitespacesWhitespaces are preserved by XML.
Namespace is not supported Namespace is supported 
HTML is a comparatively large docXML is smaller 

Leave a Reply

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

ITNETI