ashkan
ashkan

Reputation: 49

What is the type of XPath Expression

I am bit confuse about type of XPath Expression:

I have XPath Expressions as

/*/text()? What is its type?
count(/*/text()) what is its type?

what is the difference between both types.

Upvotes: 1

Views: 119

Answers (1)

Ian Roberts
Ian Roberts

Reputation: 122414

The expression /*/text() returns a node set (XPath 1.0) or sequence of nodes (XPath 2.0) consisting of all the text nodes that are immediate children of the document element. It does not include text nodes that are children of other elements, i.e. given a document

<root>foo<child>bar</child>baz</root>

/*/text() would be a set of two text nodes, one containing the text foo and the other containing baz.

The count function returns the number of nodes in a node set (XPath 1.0)/items in a sequence (XPath 2.0). In XPath 1.0 all numbers are treated as double precision floating point, in XPath 2.0 count has the more specific return type of xs:integer.

Upvotes: 1

Related Questions