public function find($css, $index = null) { $xpath = CSS::xpath_for($css); if (!isset($this->doc) || !isset($this->doc->xpath)) { return null; } if (null === $index) { return new AHTMLNodeList($this->doc->xpath->query($xpath, $this->node), $this->doc); } else { $nl = $this->doc->xpath->query($xpath, $this->node); if ($index < 0) { $index = $nl->length + $index; } $node = $nl->item($index); return $node ? new AHTMLNode($node, $this->doc) : null; } }