xpathEvaluate method
XPathSequence
xpathEvaluate(
- String expression, {
- XPathConfiguration? configuration,
- @Deprecated('Specify variables in the configuration instead') Map<
String, Object> ? variables, - @Deprecated('Specify functions in the configuration instead') Map<
XmlName, XPathFunction> ? functions,
Evaluates the given XPath expression and returns the resulting sequence.
An optional configuration can be provided to customize the evaluation
context. The returned value is of type XPathSequence.
final document = XmlDocument.parse('<books><book title="Dart"/></books>');
final count = document.xpathEvaluate('count(//book)');
Implementation
XPathSequence xpathEvaluate(
String expression, {
XPathConfiguration? configuration,
@Deprecated('Specify variables in the configuration instead')
Map<String, Object>? variables,
@Deprecated('Specify functions in the configuration instead')
Map<XmlName, XPathFunction>? functions,
}) {
var config = configuration ?? XPathConfiguration.standard();
if (variables != null || functions != null) {
config = config.copy(variables: variables, functions: functions);
}
return config.context(this).evaluate(expression);
}