What is XML?
XML is a markup language. The mighty ones who created this acronym cheated a little, as XML stands for extensible Markup Language. XML was released in the late 90's and has since received a great amount of hype. The XML standard was created by W3C to provide an easy to use and standardized way to store self-describing data (self-describing data is data that describes both its content and its structure).
XML is nothing by itself. XML is more of a "common ground" standard. The main benefit of XML is that you can use it to take data from a program like MSSQL (Microsoft SQL), convert it into XML, and then share that XML with a slough of other programs and platforms. Each of these receiving platforms can then convert the XML into a structure the platform uses normally, and presto! You have just communicated between two platforms which are potentially very different! What makes XML truly powerful is the international acceptance it has received. Many individuals and corporations have put forth their hard work to make XML interfaces for databases, programming, office application, mobile phones and more. It is because of this hard work that the tools exist to do this conversion from whatever platform into standardized XML data or convert XML into a format used by that platform.
In the past, attempts at creating a standardized format for data that could be interpreted by many different platforms (or applications) failed miserably. XML has largely succeeded in doing this.
Difference between XML and HTMLXML is not a replacement for HTML.
XML and HTML were designed with different goals:
XML was designed to describe data and to focus on what data is.
HTML was designed to display data and to focus on how data looks.
HTML is about displaying information, XML is about describing information.
XML is extensible
The tags used to markup HTML documents and the structure of HTML documents are predefined. The author of HTML documents can only use tags that are defined in the HTML standard.
XML allows the author to define his own tags and his own document structure.
XML is a complement to HTML
It is important to understand that XML is not a replacement for HTML. In the future development of the Web it is most likely that XML will be used to structure and describe the Web data, while HTML will be used to format and display the same data.
XML in future Web development
We have been participating in XML development since its creation. It has been amazing to see how quickly the XML standard has been developed, and how quickly a large number of software vendors have adopted the standard.
We strongly believe that XML will be as important to the future of the Web as HTML has been to the foundation of the Web. XML is the future for all data transmission and data manipulation over the Web
XML Syntax Rules
All XML Elements Must Have a Closing Tag
Example: <p>This is a paragraph</p>
XML Tags are Case Sensitive
Example: Opening and closing tags must be written with the same case:
<message>This is correct</message>
XML Elements Must be Properly Nested
Example: In XML, all elements must be properly nested within each other:
<b><i>This text is bold and italic</i></b>
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.
XML Attribute Values Must be Quoted
XML elements can have attributes in name/value pairs just like in HTML.
In XML the attribute value must always be quoted. Study the two XML documents below. The first one is incorrect, the second is correct:
The error in the first document is that the date attribute in the note element is not quoted.
Some characters have a special meaning in XML.
If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.
This will generate an XML error:
<message>if salary < 1000 then</message>
To avoid this error, replace the "<" character with an entity reference:
<message>if salary < 1000 then</message>
There are 5 predefined entity references in XML:
< < less than
> > greater than
& & ampersand
' ' apostrophe
" " quotation mark
Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal, but it is a good habit to replace it.
Comments in XML
The syntax for writing comments in XML is similar to that of HTML.
<!-- This is a comment -->
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.
With XML, the white-space in a document is not truncated.
XML Stores New Line as LF
In Windows applications, a new line is normally stored as a pair of characters: carriage return (CR) and line feed (LF). The character pair bears some resemblance to the typewriter actions of setting a new line. In Unix applications, a new line is normally stored as a LF character. Macintosh applications use only a CR character to store a new line.