registerNodeClass('DOMElement', 'Warp\Dom\Element'); } public function first($query) { if ($matches = $this->find($query)) { if ($matches->length) { return $matches->item(0); } } return null; } public function find($query) { return $this->xpath()->query(CssSelector::toXPath($query, 'descendant::')); } public function query($expression) { return $this->xpath()->query($expression); } public function xpath() { if (empty($this->xpath)) { $this->xpath = new \DOMXPath($this); } return $this->xpath; } }