QueryPath\CSS\QueryPathEventHandler::getMatches PHP Method

getMatches() public method

This should be called after the filter has been parsed.
public getMatches ( ) : array
return array The matched items. This is almost always an array of {@link DOMElement} objects. It is always an instance of {@link DOMNode} objects.
    public function getMatches()
    {
        //$result = array_merge($this->alreadyMatched, $this->matches);
        $result = new \SplObjectStorage();
        foreach ($this->alreadyMatched as $m) {
            $result->attach($m);
        }
        foreach ($this->matches as $m) {
            $result->attach($m);
        }
        return $result;
    }

Usage Example

コード例 #1
0
ファイル: DOMQuery.php プロジェクト: rrmodi88/querypath
 /**
  * This replaces everything that matches the selector with the first value
  * in the current list.
  *
  * This is the reverse of replaceWith.
  *
  * Unlike jQuery, DOMQuery cannot assume a default document. Consequently,
  * you must specify the intended destination document. If it is omitted, the
  * present document is assumed to be tthe document. However, that can result
  * in undefined behavior if the selector and the replacement are not sufficiently
  * distinct.
  *
  * @param string $selector
  *  The selector.
  * @param DOMDocument $document
  *  The destination document.
  * @retval object DOMQuery
  *  The DOMQuery wrapping the modified document.
  * @deprecated Due to the fact that this is not a particularly friendly method,
  *  and that it can be easily replicated using {@see replaceWith()}, it is to be
  *  considered deprecated.
  * @see remove()
  * @see replaceWith()
  */
 public function replaceAll($selector, \DOMDocument $document)
 {
     $replacement = $this->size() > 0 ? $this->getFirstMatch() : $this->document->createTextNode('');
     $c = new QueryPathEventHandler($document);
     $c->find($selector);
     $temp = $c->getMatches();
     foreach ($temp as $item) {
         $node = $replacement->cloneNode();
         $node = $document->importNode($node);
         $item->parentNode->replaceChild($node, $item);
     }
     return QueryPath::with($document, NULL, $this->options);
 }
All Usage Examples Of QueryPath\CSS\QueryPathEventHandler::getMatches