Basic XML rules: well-formed and valid XML
Element relationships within an XML document
Conceptually, the structure of an XML document is a tree structure. The root element, forms the basis of the XML tree and all other element nodes, attribute nodes and text nodes reach out like braches and leaves. Visually this could be represented as a tree graph as in the following figure of the address book in the previous section:
![]() |
Moreover, various relationships between elements exist. In the child-parent relationship one element (the child) is nested in another element (the parent). In the following example the element <name> is nested in the element <entry> and consequently <name> is the child of <entry> and <entry> the parent of <child>.
1 2 3 |
<entry> <name>Clark Kent</name> </entry> |
A sibling relationship means that elements (the siblings) have the same parent element. For instance, in our address example the elements <name>, <address> and <phoneNr> have the same parent <entry> and are hence siblings to each other:
1 2 3 4 5 |
<entry> <name>Clark Kent</name> <address>344 Clinton Street Metropolis</address> <phoneNr>55 50145</phoneNr> </entry> |
