Characteristics Of The XML Syntax

0

What Are The Characteristics Of The XML Syntax?

All the XML documents must contain a single pair of tags to define the root element.

 

Here is an example of a XML document:

<?xml version=”1.1″?>

<reminder>

    <to>Greg</to>

    <from>Jonas</from>

    <heading>Quick word</heading>

    <body>Remember what we talked about!</body>

</reminder>

 

The first instruction from the document: declaring in XML: it must always be included. This way, the program knows what set of rules to use. In our case, it is the set of the 1.1 version of XML.

The next line defines the first element of the document (the root element):

<reminder>

the next 4 instructions define the child-elements of the roots (to, from, heading and body)

The last instruction defines the closing of the root element:

</reminder>

 

Any HTML element must have a closing tag. In HTML, some of the elements have a closing tag. The next code is functional for HTML:

 

<p>The beginning phrase

<p>The ending phrase

In XML, all the elements must have a closing tag, as follows:

<p>The beginning phrase</p>

<p>The ending phrase</p>

 

The XML tags are case sensitive (they can make a difference between capital and small letters. Therefore, opening and closing the tags must be made using the same letter.

 

<Tag>This is wrong</tag>

 

<Tag>This is good</Tag>

all the XML elements must be correctly opened and closed

in HTML, some elements could be wrongly opened and closed, as follows:

 

<b><i> </b></i>

This line is wrong. Here is the correct line:

<b><i> This is a bold and italic phrase </i></b>

 

All the XML documents must have a root tag.

All the XML elements must contain a single pair of tags designed to define the root element. Any element could contain several secondary elements.

The attributes must always be quoted. The XML elements could have attributes just like the ones from HTML. Let’s see two examples to identify the difference between them:

 

<?xml version=”1.1″?>

    <date=12/05/11>

        <to>Jane</to>

        <from>Jessica</from>

        <heading>Quick word</heading>

        <body>Don’t forget our last discussion!</body>

    </note>

 

<?xml version=”1.1″?>

    <date=”12/05/11″>

        <to>Jane</to>

        <from>Jessica</from>

        <heading>Quick word</heading>

        <body>Don’t forget our last discussion!</body>

    </note>

 

If you are not careful, you won’t be able to spot the difference. In the first sequence, the date is not quoted and it also represents the beginning of the sequence. In this case, XML considers the date as a calendar element. In the second sequence, the date is quoted, being considered only as a text string.

This aspect might not be important now. However, if you want to know advanced XML, you will have to understand the differences. While a string row can’t be used for anything else than displaying data. On the other hand, the calendar data can be extracted and used for other documents.

For example, calendar data can be used to generate sales reports. It is mostly important for companies that need to generate a new script for every report needed. It is believed that the next XML versions will be able to use a single script to generate different reports, and the work of the programmers and the IT departments will be substantially eased.

Leave a Reply

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