XML - (Structured) Document

Card Puncher Data Processing


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 XML being used.

A document begins in a “root” or document entity.

Each XML document contains one or more elements.

A data object is an XML document if it is well-formed, as defined in this specification.

An XML document is valid if it has an associated document type declaration and if the document complies with the constraints expressed in it.

An XML document may consist of one or many storage units, called entities.


Even though the text in an address book may not permit bold, italics, colors, and font sizes today, one day you may want to handle these things. Because DOM will handle virtually anything you throw at it, choosing DOM makes it easier to future-proof your application.


Document oriented

<memo importance='high'
  <from>Paul V. Biron</from>
  <to>Ashok Malhotra</to>
  <subject>Latest draft</subject>
    We need to discuss the latest
    draft <emph>immediately</emph>.
    Either email me at <email>
    mailto:[email protected]</email>
    or call <phone>555-9876</phone>

Text and elements can be freely intermixed in a DOM hierarchy. That kind of structure is called mixed content in the DOM model and occurs frequently in documents.

For example, suppose you wanted to represent this structure:

<sentence>This is an <bold>important</bold> idea.</sentence>

The hierarchy of DOM nodes would look something like this, where each line represents one node:

ELEMENT: sentence
   + TEXT: This is an
   + ELEMENT: bold
       + TEXT: important
   + TEXT: idea.

The sentence element contains text, followed by a sub-element, followed by additional text. It is the intermixing of text and elements that defines the mixed-content model.

In this example, the “content” of the first element (its value) simply identifies the kind of node it is. First-time users of a DOM are usually thrown by this fact. After navigating to the

node, they ask for the node's “content”, and expect to get something useful. Instead, all they can find is the name of the element, sentence.

The value of an element is not the same as its content.


Data oriented. Standards such as JDOM and dom4j, on the other hand, make it easier to do simple things, because each node in the hierarchy is an object.

Although JDOM and dom4j make allowances for elements having mixed content, they are not primarily designed for such situations. Instead, they are targeted for applications where the XML structure contains data.

The elements in a data structure typically contain either text or other elements, but not both. For example, here is some XML that represents an invoice:

   <name>Ashok Malhotra</name>
   <street>123 Microsoft Ave.</street>

See DOM - HTML vs XML document

Discover More
Browser - Document variable (DOM) - Javascript

In a browser, the document is: a DOM document (in-memory tree) of a XML document (generally a HTML dom document) The document is provided by the browser via its DOM webapi (Not by the Javascript...
DOM - Document (Object)

Every XML doc and HTML document (Web page) in an HTML UA is represented by a TR/html5/dom.htmlDocument object. A document in the context of a browser is generally a HTML document (Web Page). The Document...
DOM - HTML vs XML document

The DOM specification gives the distinction between this two type of document: XML documents (ie XHTML) and HTML documents. HTML elements are rarely nested. In a XML file, the subsection (SECT)...
Card Puncher Data Processing
Extensible Markup Language (XML)

is a flexible way to create common information formats and to share the formats and data between applications and on the internet. XML is, essentially, a platform-independent means of structuring informationelementschemjsoXML...
Lighthouse Doctype Mandatory
HTML - doctype

The doctype is the first line of a xml document that defines its type. For a html document, it's: EOL character It's mandatory otherwise the browser will turn into quirks mode and some library...
HyperText markup Language ( HTML )

What is HTML ? the HyperText markup Language
Java Conceptuel Diagram
Java XML - DOM

in JAVA Type Best suited API XML Schema supported Document DOM JAXP Yes Data JDOM, dom4j, regular-expression No Standards such as JDOM and dom4j are targeted for applications where the XML...
Jaxpintro Domapi
Java XML - DOM Jaxp

The DOM API of the JSE (ie Jaxp) in Java to process an XML file. To see other DOM implementation, see org.w3c.dom: Defines the Document class (a DOM) as well as classes for all the components...
The Document Object Model W3C API Interface (DOM)

W3CAPI The domDocument Object Model (DOM) is one of the two programming models used to represent a XML document. DOM defines the interface description of a Document Object that represents an XML document...
Utah Teapot
Viz - Scene Graph - Graphical World (Tree Data Structure)

A scene graph is a collection of nodes in a tree structure. It's equivalent to a document in xml The node of the tree are: a graphical object for the leaf a compound object such as: or a group...

Share this page:
Follow us:
Task Runner