Comparing HTML and XML

XML can, in some respects, be considered an extensible form of HTML. This is because HTML is restrictive in terms of the tags it is allowed to use. In the following sample HTML document, all tags, such as <HTML> , are predefined:

   <HTML> <HEAD><TITLE>This is a simple HMTL page</TITLE></HEAD> <BODY> <P> Once more unto the breach, dear friends, once more; or close the wall up with our English dead. In peace there's nothing so becomes a man as modest stillness and humility; but when th' blast of war blows in our ears, then imitate the action of the tiger: stiffen the sinews, summon up the blood, disguise fair nature with hard-favour'd rage; then lend the eye a terrible aspect. <P> Cry 'Havoc !' and let slip the dogs of war, that this foul deed shall smell above the earth with carrion men, groaning for burial. </P> </BODY> </HTML>   

Figure 1-1 shows the execution of this script in a browser. You can see in the figure that none of the tags appear in the browser, only the text between the tags. In the preceding sample HTML page code, the tags are all predefined and enclosed within angle brackets (< . . . >) . An HTML document will always begin with the tag <HTML> and end with the corresponding closing tag </HTML> . Other tags shown in the above script are <HEAD> , <TITLE> , <BODY> , and <P> . The <P> tag is used for paragraphs.

image from book
Figure 1-1: A simple sample HTML page

Unlike HTML, XML is extensible and thus is capable of being extended or modified by changing or adding features. XML can have tags of its own created (customized) that are unique to every XML document created. An XML document when embedded into an HTML page needs the predefined tag that an HTML page does, such as <HTML> and <P> , but XML can also make up its own tags as it goes along.

An important restriction with respect to the construction of XML documents that is not strictly applied in HTML code is that all tags must be contained within other tags. The root node tag is the only exception. Examine the previous HTML coding example and you will see that in the source code the first paragraph does not have a terminating </P> tag (using the / or forward slash character). HTML does not care about this. XML does!



Beginning XML Databases
Beginning XML Databases (Wrox Beginning Guides)
ISBN: 0471791202
EAN: 2147483647
Year: 2006
Pages: 183
Authors: Gavin Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net