You are here

public function QueryPathCssEventHandler::elementNS in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::elementNS()
  2. 7.2 QueryPath/CssEventHandler.php \QueryPathCssEventHandler::elementNS()

Overrides CssEventHandler::elementNS

File

QueryPath/CssEventHandler.php, line 121

Class

QueryPathCssEventHandler

Code

public function elementNS($lname, $namespace = NULL) {
  $this->findAnyElement = FALSE;
  $found = new SplObjectStorage();
  $matches = $this
    ->candidateList();
  foreach ($matches as $item) {
    $nsuri = $this->dom
      ->lookupNamespaceURI($namespace);
    if ($item instanceof DOMNode && $item->namespaceURI == $nsuri && $lname == $item->localName) {
      $found
        ->attach($item);
    }
    if (!empty($nsuri)) {
      $nl = $item
        ->getElementsByTagNameNS($nsuri, $lname);
      if (!empty($nl)) {
        $this
          ->attachNodeList($nl, $found);
      }
    }
    else {
      $nl = $item
        ->getElementsByTagName($lname);
      $tagname = $namespace . ':' . $lname;
      $nsmatches = array();
      foreach ($nl as $node) {
        if ($node->tagName == $tagname) {
          $found
            ->attach($node);
        }
      }
    }
  }
  $this->matches = $found;
}