Short for extensible markup language, XML is a specification developed by W3C starting with the recommendation on February 10, 1998. XML is similar to HTML in that XML uses tags to markup a document, allowing the browser to interpret the tags and display them on a page. However, unlike HTML, XML language is unlimited (extensible). It allows tags to define themselves, and can describe the content instead of only displaying a page's content. Using XML other languages such as RSS and MathML have been created, even tools like XSLT were created using XML.
Example of XML code
Below is a basic example of how XML code may appear. As mentioned earlier, you can use whatever tags you want to use as long as they follow all of the rules. Also, because there is no defined rules, structure, and any tag can be placed anywhere, a DTD (document type definition) needs to be defined with instructions and structure of your XML.
<?xml version="1.0" encoding="utf-8"?>
<description>Microsoft Windows 8 operating system - Full version.</description> <developer>Microsoft</developer> <cost>132.78</cost>
<name>World of Warcraft</name>
<description>World of Warcraft for Mac and PC.</description>
How do you create XML?
Like HTML, XML can be created using any text editor. However, is easier to create using either an HTML editor with XML syntax highlighting like Dreamweaver or a text editor with syntax highlighting like Notepad++.
Rules to remember when creating XML
Although the XML language is unlimited when it comes to defining tags, there are still rules that need to be followed when writing XML code.
- All XML opening tags must have a matching closing tag. If you have an empty tag, you can use a tag similar to: <example/>
- XML tags are case sensitive, so your opening tag should exactly match the closing tag.
- You must have a single root tag (element) that contains all other tags. In our example, "computersoftware" was our root tag.
- All tags containing an attribute must be in quotes.
- All tags must be properly nested.
Does XML replace HTML?
No. HTML is still the primary language used to create the structure of a web page. XML can be used in addition to an HTML page or as an alternative to HTML.