XPath Expressions
The most fundamental concept of XPath is the expression. An XPath expression evaluates to a value that must be of type string, boolean, number, and node-set (an ordered collection of nodes). XPath defines rules for coercing from any of the four types to a string, boolean, or number. Under certain scenarios, the coercion happens silently, based on how or where the expression is evaluated. Under other scenarios, the coercion must be made explicit by using a coercion function. Coercion between string, boolean, and number is fairly intuitive. Coercion from node-set to the other three types is not.
When a node-set is coerced to a boolean, the result is true if the node-set is nonempty, false if the node-set is empty. When a node-set ...
Get Essential XML: Beyond Markup now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.