DOM - HTML vs XML document

About

The DOM specification gives the distinction between this two type of document:

Properties

Nested

HTML elements are rarely nested.

In a XML file, the subsection (SECT) can be totally contained within the major section (SECT). They are nested.

<?xml version="1.0"?>
<ARTICLE>
   <TITLE>A Sample Article</TITLE>
   <SECT>The First Major Section
      <PARA>This section will introduce a subsection.</PARA>
      <SECT>The Subsection Heading
         <PARA>This is the text of the subsection.
         </PARA>
      </SECT>
   </SECT>
</ARTICLE>

In HTML, on the other hand, headings do not contain the body of a section.

<BODY>
   <H1>The First Major Section</H1>
      <P>This section will introduce a subsection.</P>
      <H2>The Subsection Heading</H2>
         <P>This is the text of the subsection.</P>
</BODY>

Level

HTML goes down only to five levels.

Strictness

The following are not valid in XML/XHTML

<!-- valid HTML, non XML valid -->
<meta name="generator" content="datacadamia">
<!-- valid XHTML -->
<meta name="generator" content="datacadamia"/>





Discover More
HTML - Document

An HTML document is a well-formed HTML string (ie that contains the html root element). web page The HTML textual representation can be stored: in a string in a file or in the body of an HTTP...
Card Puncher Data Processing
XML - Extensible HTML (XHTML)

Extensible HTML (XHTML) is an XML document: that looks like HTML but is well formed according to XML rules. See also In 1998 , the W3C membership decided to stop evolving HTML and instead begin...
Card Puncher Data Processing
XML - (Structured) Document

Documents are built from node (elements and text node between node element). These elements form a tree using the DOM. Each XML documents begin with an XML declaration which specifies the version of...



Share this page:
Follow us:
Task Runner