XML can store data, but it is not a database. XML can serialize objects, but an XML document is not an object. Web pages can be written in XML, but XML is not HTML. Functional (and other) programming languages can be written in XML, but XML is not a programming language. Books are written in XML, but that doesn't make XML desktop publishing software.
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.
Here are some examples:
XML Makes Your Data More Available
Since XML is independent of hardware, software and application, XML can make your data more available and useful.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.
XML is Used to Create New Internet Languages
A lot of new Internet languages are created with XML.Here are some examples:
- XHTML the latest version of HTML
- WSDL for describing available web services
- WAP and WML as markup languages for handheld devices
- RSS languages for news feeds
- RDF and OWL for describing resources and ontology
- SMIL for describing multimedia for the web
An Example XML Document
XML documents use a self-describing and simple syntax:
<note><to>Toveto><from>Janifrom><heading>Reminderheading><body>Don't forget me this weekend!body>note>The first line is the XML declaration. It defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/West European character set).
The next line describes the root element of the document (like saying: "this document is a note"):
Tove
Jani
Reminder
Don't forget me this weekend!
All elements can have sub elements (child elements):
.....
Example:
The image above represents one book in the XML below:
Giada De Laurentiis
2005
30.00
J K. Rowling
2005
29.99
Erik T. Ray
2003
39.95
All elements must have a closing tag:
This is a paragraph
This is another paragraph
XML Tags are Case Sensitive
XML Elements Must be Properly Nested
This text is bold and italicXML 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.
.....
XML Attribute Values Must be Quoted
This will generate an XML error:
if salary < 1000 then
if salary < 1000 then
< < less than > > greater than & & ampersand ' ' apostrophe " " quotation mark
White-space is Preserved in XML
HTML truncates multiple white-space characters to one single white-space:
HTML: Hello my name is Tove Output: Hello my name is Tove.
XML Stores New Line as LF