Data Models
Tree Structure
An XML document can be represented as a hierarchical tree structure where:
The root element is the top-level node.
Each element is a node.
Nodes can have child nodes (nested elements).
Nodes can have attributes and text content.
This tree structure allows easy traversal, querying, and manipulation of XML data.
Example Tree Representation
<library>
<book id="1">
<title>XML Basics</title>
<author>John Doe</author>
</book>
<book id="2">
<title>Advanced XML</title>
<author>Jane Smith</author>
</book>
</library>Root node:
<library>Child nodes: Two
<book>elementsEach
<book>node has child nodes<title>and<author>, and an attributeid.
Visual Example
Document Object Model
Key Points
DOM represents the XML document as nodes in a tree.
Nodes include elements, attributes, text, comments, etc.
Allows traversal and manipulation of the XML structure.
Available in many programming languages (JavaScript, Java, Python, C#, etc.).
Basic DOM Operations (Example in JavaScript)
DOM Node Types
Element Node
An element like <book>
Attribute Node
Attribute of an element
Text Node
Text content inside elements
Comment Node
XML comments
Document Node
The entire XML document
Last updated