xpath method

Iterable<XmlNode> xpath(
  1. String expression, {
  2. XPathConfiguration? configuration,
  3. @Deprecated('Specify variables in the configuration instead') Map<String, Object>? variables,
  4. @Deprecated('Specify functions in the configuration instead') Map<XmlName, XPathFunction>? functions,
})

Returns an iterable over the nodes matching the provided XPath expression.

An optional configuration can be provided to customize the evaluation context. The returned nodes are a lazy iterable of XmlNode instances.

final document = XmlDocument.parse('<books><book title="Dart"/></books>');
final titles = document.xpath('//book/@title');

Implementation

Iterable<XmlNode> xpath(
  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,
}) => xpathEvaluate(
  expression,
  configuration: configuration,
  variables: variables,
  functions: functions,
).whereType<XPathNode>().map((item) => item.node);