You are here

public function XMLXpath::resolve in GraphQL 8.4

Execute the XPath query and return matching DOMElements.

Parameters

\DOMElement $dom: The source (root) DOM element.

string $query: The xpath query.

Return value

\DOMElement[]

File

src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php, line 40

Class

XMLXpath
XPath query data producer.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\XML

Code

public function resolve(\DOMElement $dom, $query) {
  $xpath = new \DOMXPath($dom->ownerDocument);
  return iterator_to_array($xpath
    ->query($query, $dom));
}