DOM - HTML vs XML document

> (World Wide) Web - (W3|WWW) > The Document Object Model W3C API Interface (DOM)

1 - About

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

3 - Properties

3.1 - 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>
Advertising

3.2 - Level

HTML goes down only to five levels.