Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML with the Document Object Model (DOM) : XML terminology : XML document structure : XML elements
 
XML elements
Elements represent the logical components of documents. They can contain data or other elements. For example, a customer element can contain a number of column (field) elements and each column element can contain one data value. An element is composed of a start tag, data, and an end tag. Here is an example of an element:
 Start tag       Data             End tag
|-------------||---------------||--------------|
<customer-name>Clyde Peter Jones</customer-name>
Here is an example of elements that contain other elements:
<phone>
    <entry>
        <name>Chip</name>
        <extension>3</extension>
     </entry>
</phone>
In this example, name and extension are child elements of entry, which is a child element of phone. Similarly, phone is a parent element of entry, which is a parent element of name and extension.
The top-level element, the one that is the parent of all other elements is referred to as the root element. A child element that cannot have its own child elements, as defined by the DTD or XML Schema, is referred to as a leaf element. In the example above, name and extension are leaf elements.
To conclude, a typical discussion of XML elements that describes hierarchy will use these terms:
*Root element
*Parent element
*Child element
*Leaf element
In the previous example, the XML contains whitespace to make the logical, hierarchical structure of the XML apparent to human readers. XML is valid with or without this whitespace. The following version is also valid XML:
<phone><entry><name>Chip</name><extension>3</extension></entry></phone>