You are here

protected function QueryPath::deepestNode in QueryPath 7.2

Same name and namespace in other branches
  1. 6 QueryPath/QueryPath.php \QueryPath::deepestNode()
  2. 7.3 QueryPath/QueryPath.php \QueryPath::deepestNode()
4 calls to QueryPath::deepestNode()
QueryPath::deepest in QueryPath/QueryPath.php
QueryPath::wrap in QueryPath/QueryPath.php
QueryPath::wrapAll in QueryPath/QueryPath.php
QueryPath::wrapInner in QueryPath/QueryPath.php

File

QueryPath/QueryPath.php, line 869

Class

QueryPath

Code

protected function deepestNode(DOMNode $ele, $depth = 0, $current = NULL, &$deepest = NULL) {
  if (!isset($current)) {
    $current = array(
      $ele,
    );
  }
  if (!isset($deepest)) {
    $deepest = $depth;
  }
  if ($ele
    ->hasChildNodes()) {
    foreach ($ele->childNodes as $child) {
      if ($child->nodeType === XML_ELEMENT_NODE) {
        $current = $this
          ->deepestNode($child, $depth + 1, $current, $deepest);
      }
    }
  }
  elseif ($depth > $deepest) {
    $current = array(
      $ele,
    );
    $deepest = $depth;
  }
  elseif ($depth === $deepest) {
    $current[] = $ele;
  }
  return $current;
}