Text nodes

A text node encapsulates XML character content.

A text node can have zero or one parent. The content of a text node can be empty. However, unless the parent of a text node is empty, the content of the text node cannot be an empty string. Text nodes that are children of a document or element node never appear as adjacent siblings. During document or element node construction, any adjacent siblings are combined into a single text node. If the resulting text node is empty, it is discarded.

Text nodes have the following node properties:
  • content
  • parent
For example, suppose that a document has the following textual representation:
<product xmlns="http://posample.org" pid="100-101-01">  
  <description>                                               
    <name>Snow Shovel, Deluxe 24"</name>                       
    <details>A Deluxe Snow Shovel, 24 inches wide, ergonomic
            curved handle with D-Grip</details>                                       
    <price>19.99</price>                                       
    <weight>2 kg</weight>                                    
  </description>                                           

The text node beneath the name element node has the following property values:

Table 1. Properties of the name text node
Node property Value
content Snow Shovel, Deluxe 24"
parent name
The string value of a text node is the content of the node, which in the preceding example is " Snow Shovel, Deluxe 24" ." The typed value of a text node is the same value as the string value and is type xs:untypedAtomic.