What is XML Code?
XML is a document formatter. It emphasizes simplicity, generality, and usability. Documents and web pages written in the XML format can appear anywhere over the Internet. It is a textual data format, with support using Unicode for the languages of the world. It has a design focus on documents, so it is widely used to represent arbitrary data structures like web services.
XML as Text Data
If a programmer wishes to describe data, he uses XML. If the programmer wishes to modify how the data looks, she uses HTML. XML does not do anything. Instead, XML will store, structure, and transport information. As software, XML is nothing special and does nothing special. It is plain text. It is universal because software that can handle plain text can also handle XML.
XML, despite its popularity, is not a replacement for HTML. Even though XML will be found In most web applications, it will only transport data; to format and display data turn to HTML. XML is an independent protocol; it is both a software and a hardware independent tool for transporting information.
Source: Introduction to XML
Examples of XML and HTML
Both XML and HTML use tags. All tags that are opened must be closed; think of a quotation. One quotation mark starts the quote, and the second quotation mark closes the quote: "Happy Time". A tag is opened this way: <tag>, and it is closed this way </tag>. So if we open a new tag <bold> we close it with the tag </bold>.
XML is different from HTML. So here are two samples of code. The first is XML.
This is content.
These items are tags, and they are free form. The programmer creates them.
Now here is an example of HTML tags:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
The tags in the HTML example are predefined. The programmer must use them. They are not free form.
Source: Learn XML in 11.5 minutes
Source: HTML Introduction
HTML pages will often store data, so the HTML pages will frequently display that data. However, with XML this data can be isolated in a separate XML file. One can focus on using HTML for formatting and display and be assured that changes made to the underlying data will not filter up and force changes to any of the HTML code.
Another feature is that XML data can be placed inside HTML pages as "Data Islands." In this way, programmers can still concentrate on using HTML for formatting as well as displaying the data.
Very often, with computer systems and databases, data will be available in incompatible formats. Programmers know what a time consuming challenge it is for developers to exchange data between different systems over the Internet. However, converting the data to XML will reduce the complexity and create data that can be read by different types of applications.
XML is a text-based document formatter that works with HTML. XML is hardware and software independent. This allows it to be used by any program that can read text. XML describes data as opposed to HTML, which formats it. XML uses tags, but those tage are programmer defined–unlike HTML, in which the tags are predefined.