The following article http://docs.oracle.com/javaee/1.4/tutorial/doc/JAXPXSLT3.html says that XPATH considers the following to be nodes:
- Root
- Element
- Text
- Attribute
- Comment
- Processing instruction
- Namespace
What I want to know is whether an attribute ‘id’ and its value ‘2’ are considered to be two different nodes? e.g. <name id="2">text</name>
Or are text nodes just the ‘data’ http://www.w3.org/XML/Datamodel.html between elements? My intuition tells me that XPATH would consider there to be 4 nodes in this example – the ‘name’ element, the attribute ‘id’ the text value ‘2’ and the text value ‘text’.
An attribute node has a name and a value. They are not separate nodes. The following XML:
…represents three nodes: 1) an element whose name is
name; 2) a child node ofnamethat is a text node; 3) an attribute node whose name isidand whose value is2.From the spec:
And later: