In addition to specifying a node's relationship to other nodes in the tree, XPath defines a name and a string value for each node type, as follows:
Node Type | Node Name | Node Value |
---|---|---|
Root | Empty string ("") | Concatenated value of text in all descendant element nodes and text nodes. |
Element | Element name (expanded form, including namespace URI, if any) | Concatenated value of text in all descendant element nodes and text nodes. |
Attribute | Attribute name (expanded form, including namespace URI, if any) | The value of the attribute. |
Text | Empty string ("") | All text in that node (multiple end-of-line sequences normalized to single newline). |
Processing-instruction | The target of the processing instruction | Everything in the processing instruction, except for the target and the white space that follows the target. |
Comment | Empty string ("") | All text between the opening <! -- and closing --> delimiters. |
Namespace | Namespace prefix (excluding ":"), or empty string (""), if no prefix is declared for the namespace | The URI which is bound to the namespace. |
The following are some of the node names and values associated with the node tree that is presented as a diagram in XPath Nodes Example.
Node | Name | String Value |
---|---|---|
Root | Empty string ("") | "http//www.example.microsoft.com/catalogbk101$#71;Ambercrombie, KimXMLDeveloper's $#x47;uideComputer44.952000-10-01and&." plus text from the remaining <book> element |
Comment | Empty string ("") | "catalog last updated 2000-10-01" |
<catalog> element |
"catalog" | "http//www.example.microsoft.com/catalogbk101$#71;Ambercrombie, KimXMLDeveloper's $#x47;uideComputer44.952000-10-01and&." plus text from the remaining <book> element |
<book> element |
"book" | "bk101$#71;Ambercrombie, KimXMLDeveloper's $#x47;uideComputer44.952000-10-01and&." |
xmlns attribute | "id" | "http://www.example.microsoft.com/catalog" |
For information about references (such as $#x47; and &), see Character and Entity References.
Processing Text Strings by Using String Functions | Working with a Source Tree | Using XPath Expressions to Select Nodes | The XSLT Processor