Skip to main content

XML

XML stands for EXtensible Markup Language.

It’s a text-based markup language derived from Standard Generalized Markup Language (SGML), used for storing and transportation of data.

What is Markup Language?

XML is a markup language that explains a fixed set of rules for creating documents that are readable by humans and machines.

It is a method through which information is added to a document, which helps to identify various parts and its relation with other parts. Its simple definition is – a markup language is a set of symbols that is placed in the text of a document to distinguish and label the components/parts of that document.

Following example shows how to use XML markup language:

<Note>
<text>Hello, welcome to XML World!</text>
</Note>

why XML?

It is important to understand that XML was designed to store, carry, and exchange data. XML was not designed to display data.

Using XML to Exchange Data

With XML, you can exchange data between incompatible systems. One of the most time-consuming challenges for software developers has been to exchange data between computer systems and databases that contain data in incompatible formats. Converting the data to XML can greatly reduce this complexity and create data that can be read by many different types of applications.

Using XML to Enable B2B Transactions

Using XML, you can exchange financial information over the Internet. XML might soon become the main language for exchanging financial information between businesses over the Internet. Several interesting B2B (Business To Business) applications are currently under development.

Using XML to Share Data

With XML, you can use plain text files to share data. Since XML data is stored in plain text format, it provides a software- and hardware-independent method of sharing data. This makes it much easier to create data that different applications can use. It also makes it easier to expand or upgrade a system to new operating systems, servers, applications, and browsers.

Using XML to Store Data

With XML, you can use plain text files to store data. You can use XML to store data in files or in databases. You can write applications to store and retrieve information from the store and use generic applications to display the data.

Using XML to Provide Greater Availability

Using XML, your data is available to more users. Since XML is independent of hardware, software, and applications, you can make your data more widely available than to only standard HTML browsers. Other clients and applications can access your XML files as data sources, just as they would access databases.

XML Syntax Rules:

we must follow these rules when we create XML syntax:

  • All XML elements must have a closing tag.
  • XML tags are case sensitive. (means which show the difference between upper case letter and lower case letter)
  • All XML elements must be properly nested.
  • All XML documents must have a root element.
  • Attribute values must always be quoted.

All XML elements must have a closing tag

It is illegal to omit the closing tag when you are creating XML syntax. XML elements must have a closing tag.

Incorrect:

<body>See Spot run.
<body>See Spot catch the ball.

Correct:

<body>See Spot run.</body>
<body>See Spot catch the ball.</body>

XML tags are case sensitive

When you create XML documents, the tag <Body> is different from the tag <body>.

Incorrect:

<Body>See Spot run.</body>

Correct:

<body>See Spot run.</body>

All XML elements must be properly nested

Improper nesting of tags makes no sense to XML.

Incorrect:

<b><i>This text is bold and italic.</b></i>

Correct:

<b><i>This text is bold and italic.</i></b>

All XML documents must have a root element

All XML documents must contain a single tag pair to define a root element. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element.

Example:

<root>
  <child>
    <subchild>.....</subchild>
  </child>
</root>

Attribute values must always be quoted

It is illegal to omit quotation marks around attribute values. XML elements can have attributes in name/value pairs; however, the attribute value must always be quoted.

Incorrect:

<?xml version= “1.0” encoding=“UTF-8”?>
<note date=05/05/05>
<to>Dick</to>
<from>Jane</from>
</note>

Correct:

<?xml version= “1.0” encoding=“UTF-8”?>
<note date=”05/05/05”>
<to>Dick</to>
<from>Jane</from>
</note>

In the incorrect document, the date attribute in the note element is not quoted.

Comments