DB2 10.5 for Linux, UNIX, and Windows

Node hierarchies

The nodes of a sequence form one or more hierarchies, or trees, that consist of a root node and all of the nodes that are reachable directly or indirectly from the root node. Every node belongs to exactly one hierarchy, and every hierarchy has exactly one root node. DB2® supports six node kinds: document, element, attribute, text, processing instruction, and comment.
The following XML document, products.xml, includes a root element, named products, which contains product elements. Each product element has an attribute named pid (product ID) and a child element named description. The description element contains child elements named name and price.
<products>
  <product pid="10">
    <description>
      <name>Fleece jacket</name>
      <price>19.99</price>
    </description>
  </product>
  <product pid="11">
    <description>
      <name>Nylon pants</name>
      <price>9.99</price>
    </description>
  </product>
</products>
Figure 1 shows a simplified representation of the data model for products.xml. The figure includes a document node (D), element nodes (E), attribute nodes (A), and text nodes (T).
Figure 1. Data model diagram for products.xml document
Data model diagram for products.xml document

As the example illustrates, a node can have other nodes as children, thus forming one or more node hierarchies. In the example, the element product is a child of products. The element description is a child of product. The elements name and price are children of the element description. The text node with the value Fleece Jacket is a child of the element name, and the text node 19.99 is a child of the element price.