[Overview][Types][Classes][Procedures and functions][Index] |
Evaluates an XPath expression using the specified context node and optional namespace resolver.
Source position: laz2_xpath.pas line 466
function EvaluateXPathExpression( |
const AExpressionString: DOMString; |
AContextNode: TDOMNode; |
AResolver: TXPathNSResolver = Nil |
AExpressionString |
|
XPath expression evaluated in the routine. |
AContextNode |
|
Context node for the XPath expression. |
AResolver |
|
Namespace resolver for the evaluation. |
XPath variable representing the evaluated XPath expression.
EvaluateXPathExpression is a TXPathVariable function used to locate and return a node or tree of nodes that match the XPath expression specified in AExpressionString. AExpressionString is similar to a SQL query, and is used to navigate and select DOM nodes found in the AContextNode argument.
Some examples (for specific xml document content) include:
/bookstore/book /bookstore/book[1] /bookstore/book[last()] /bookstore/book[price<35.00]/title //title[@lang] //title[@lang="en"] //title[starts-with(text(),"Introduction to")] //book[@genre="Science Fiction"] //*[contains(@class, "nav")]
XPath expressions and syntax are defined in the specification located at:
XML Path Language (XPath) Version 1.0, W3C Recommendation, 16 November 1999
AContextNode is a DOM node in an existing XML document, and provides the node tree searched in the routine. It may be be the root element in an XML document, but may also contain one the child nodes in a document to perform a limited search.
AResolver is a TXPathNSResolver instance which allows namespace prefixes and URLs to be validated while evaluating the XPath expression. It is an optional argument (the default value is Nil), and when omitted causes only the namespaces defined in AContextNode to be considered valid. The resolver instance must be created (when needed) using a DOM node which contains the namespace declarations for node prefixes that can be included in the XPath expression, and the nodes in the result set.
EvaluateXPathExpression creates a TXPathScanner instance used to parse and process the XPath expression, and to compare DOM nodes for inclusion in a result set. It is passed as an argument a TXPathExpression instance also created in the routine, and used to build the DOM tree that is the return value for the function. The evaluator is configured to perform a complete evaluation of the XPath expression, including phrases which are non-deterministic. It also returns the TXPathVariable instance with the DOM node(s) which match the evaluated expression.
The TXPathVariable return value may be cast to a type expected in the application using methods like AsNodeSet, AsBoolean, or AsText. It may also be cast to a specific class type like TXPathNodeSetVariable, TXPathBooleanVariable, TXPathNumberVariable, or TXPathStringVariable.
|
Evaluates an XPath expression using the scanner for the class instance with the specified context node and XPath environment. |
|
|
Implements a lexical scanner and parser using XPath syntax and semantics. |
|
|
Implements a Namespace resolver for the XPath environment. |
|
|
Base class used to represent an XPath variables and results. |
|
|
Represents an XPath Node Set variable. |
|
|
Represents an XPath Boolean variable. |
|
|
Represents an XPath Number variable. |
|
|
Represents an XPath String variable. |
|
|
Implements the DOM Node interface. |
Version 4.0 | Generated 2025-05-03 | Home |