XML
(Website Development)
Neeraj Kr. Gupta
Asstt. Prof.
IIMTEC, Meerut
How Can XML be Used?
XML is used in many aspects of web development, often to simplify data storage and
sharing.
1. XML Separates Data from HTML
If you need to display dynamic data in your HTML document, it will take a lot of work
to edit the HTML each time the data changes.
With XML, data can be stored in separate XML files. This way you can concentrate on
using HTML/CSS for display and layout, and be sure that changes in the underlying
data will not require any changes to the HTML.
2. XML Simplifies Data Sharing
In the real world, computer systems and databases contain data in incompatible
formats.
XML data is stored in plain text format. This provides a software- and hardware-
independent way of storing data. This makes it much easier to create data that can be
shared by different applications.
3. XML Simplifies Data Transport
One of the most time-consuming challenges for developers is to
exchange data between incompatible systems over the Internet.
Exchanging data as XML greatly reduces this complexity, since the data
can be read by different incompatible applications.
4. XML Simplifies Platform Changes
Upgrading to new systems (hardware or software platforms), is always
time consuming. Large amounts of data must be converted and
incompatible data is often lost.
XML data is stored in text format. This makes it easier to expand or
upgrade to new operating systems, new applications, or new browsers,
without losing data.
5. XML Makes Your Data More Available
Different applications can access your data, not only in HTML pages, but
also from XML data sources.
With XML, your data can be available to all kinds of "reading machines"
(Handheld computers, voice machines, news feeds, etc.), and make it
more available for blind people, or people with other disabilities.
Internet Languages Written in XML
Several Internet languages are written in XML. Here are some examples:
XHTML
XML Schema
SVG
WSDL
RSS
XML Syntax Rules
The syntax rules of XML are very simple and logical as follows :
1. All XML Elements Must Have a Closing Tag
In XML, it is illegal to omit the closing tag. All elements must have a
closing tag:
<p>This is a paragraph.</p>
<br />
2. XML Tags are case sensitive
XML tags are case sensitive.
The tag <Letter> is different from the tag <letter>.
Opening and closing tags must be written with the same case:
<Message>This is incorrect</message>
<message>This is correct</message>
3. XML Elements Must be properly nested
In XML, all elements must be properly nested within each other:
<b><i>This text is bold and italic</i></b>
4. XML documents must have a root element
XML documents must contain one element that is the parent of all other
elements. This element is called the root element.
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
5. XML Attribute values must be quoted
XML elements can have attributes in name/value pairs just like in HTML.
In XML, the attribute values must always be quoted as follows :
<note date="12/11/2007">
<to>Tove</to>
<from>Jani</from>
</note>