Skip to main content

XML DOM Model

A DOM document is a collection of nodes or pieces of information, organized in a hierarchy.

XML DOM Structure

Everything in an XML document is a node and even the document itself is a node.

Some types of nodes can have children nodes of various types, and others are leaf nodes that cannot have anything under them in the document structure.

The following table shows the various types of nodes and for each the possible child nodes:

NodeChild nodes
DocumentElement (maximum of one), ProcessingInstruction, Comment, DocumentType (maximum of one)
DocumentFragmentElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
EntityReferenceElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
ElementElement, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
AttrText, EntityReference
ProcessingInstructionNo children
CommentNo children
TextNo children
CDATASectionNo children
EntityElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
NotationNo children

Example

<?xml version = "1.0"?>
<Company>
<Employee category="technical">
<FirstName>Tom</FirstName>
<LastName>Nolan</LastName>
<ContactNo>1234567890</ContactNo>
</Employee>
<Employee category="support">
<FirstName>Ryan</FirstName>
<LastName>Reynolds</LastName>
<ContactNo>1123456789</ContactNo>
</Employee>
</Company>
note

Learn more about Nodes in XML DOM Nodes chapter.

Table of Contents