Recursive DOM node iterator constructor

@param \DOMNodeList|array $nodeList Node list
@throws RuntimeException If the node list is invalid
@return array Nodes
194232
protected function registerNodes($nodeList)
    {
        // If the node list is invalid
        if (!is_array($nodeList) && !($nodeList instanceof \DOMNodeList)) {
            throw new RuntimeException(RuntimeException::INVALID_NODE_LIST_STR, RuntimeException::INVALID_NODE_LIST);
        }

        $nodes = [];

        // Run through and register all nodes
        /** @var \DOMNode $node */
        foreach ($nodeList as $node) {
            $nodes[$node->getNodePath()] = $this->registerNode($node);
        }

        return $nodes;
    }
1192368
public function getNativelyNodeChildren($nodeUid)
    {
        $query = $this->createQueryBuilder('s')
                ->select('s._uid', 's._leftnode')
                ->where('s._parent = :node')
                ->addOrderBy('s._leftnode', 'asc')
                ->addOrderBy('s._modified', 'desc')
                ->getQuery()
                ->getSQL();

        $result = $this->getEntityManager()
                ->getConnection()
                ->executeQuery((string) $query, [$nodeUid], [\Doctrine\DBAL\Types\Type::STRING])
                ->fetchAll();

        return Collection::array_column($result, 'uid0');
    }
916801
protected function getItems( \DomNodeList $nodes )
	{
		$codes = $map = [];
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product' );

		foreach( $nodes as $node )
		{
			if( $node->nodeName === 'productitem' && ( $attr = $node->attributes->getNamedItem( 'ref' ) ) !== null ) {
				$codes[$attr->nodeValue] = null;
			}
		}

		$search = $manager->createSearch()->setSlice( 0, count( $codes ) );
		$search->setConditions( $search->compare( '==', 'product.code', array_keys( $codes ) ) );

		foreach( $manager->searchItems( $search, [] ) as $item ) {
			$map[$item->getCode()] = $item;
		}

		return $map;
	}
900533
protected function startClean(\DOMNodeList $elements)
    {
        // loop through all elements
        // we do this backwards so we don't skip anything if we delete a node
        // see comments at: http://php.net/manual/en/class.domnamednodemap.php
        for ($i = $elements->length - 1; $i >= 0; $i--) {
            $currentElement = $elements->item($i);

            // If the tag isn't in the whitelist, remove it and continue with next iteration
            if (!in_array(strtolower($currentElement->tagName), $this->allowedTags)) {
                $currentElement->parentNode->removeChild($currentElement);
                $this->xmlIssues[] = array(
                    'message' => 'Suspicious tag \'' . $currentElement->tagName . '\'',
                    'line' => $currentElement->getLineNo(),
		);
                continue;
            }

            $this->cleanAttributesOnWhitelist($currentElement);

            $this->cleanXlinkHrefs($currentElement);

            $this->cleanHrefs($currentElement);

            if (strtolower($currentElement->tagName) === 'use') {
                if ($this->isUseTagDirty($currentElement)) {
                    $currentElement->parentNode->removeChild($currentElement);
                    $this->xmlIssues[] = array(
                        'message' => 'Suspicious \'' . $currentElement->tagName . '\'',
			'line' => $currentElement->getLineNo(),
                    );
                    continue;
                }
            }
        }
    }
1273843
public function nodeListToArray(DOMNodeList $pNodeList)
    {
        $values = array();

        if ($pNodeList === false or ! $pNodeList->length) {
            return $values;
        }

        foreach ($pNodeList as $node) {
            if ($node instanceof DOMElement) {
                if ($node->childNodes and $node->childNodes->length > 1 or ($node->childNodes and $node->childNodes->length == 1 and ! $node->childNodes->item(0) instanceof DOMText)) {
                    $attributes = $this->_getNodeAttributes($node);

                    if (! array_key_exists($node->nodeName, $values)) {
                        if (empty($attributes)) {
                            $values[$node->nodeName] = $this->nodeListToArray($node->childNodes);
                        } else {
                            $values[$node->nodeName] = array_merge($this->nodeListToArray($node->childNodes), $attributes);
                        }
                    } else {
                        if (! is_array($values[$node->nodeName]) or ! array_key_exists(0, $values[$node->nodeName])) {
                            $values[$node->nodeName] = array($values[$node->nodeName]);
                        }

                        if (empty($attributes)) {
                            $values[$node->nodeName][] = $this->nodeListToArray($node->childNodes);
                        } else {
                            $values[$node->nodeName][] = array_merge($this->nodeListToArray($node->childNodes), $attributes);
                        }
                    }
                } else {
                    $attributes = $this->_getNodeAttributes($node);
                    $query = $this->xPathQuery('.//' . $node->nodeName, $node->parentNode);

                    if ($query->length > 1) {
                        if (isset($values[$node->nodeName]) and ! array_key_exists(0, $values[$node->nodeName])) {
                            $values[$node->nodeName] = array($values[$node->nodeName]);
                        }
                        if (empty($attributes)) {
                            $values[$node->nodeName][] = $node->nodeValue;
                        } else {
                            if ($node->nodeValue) {
                                $values[$node->nodeName][] = array_merge(array($node->nodeValue), $attributes);
                            } else {
                                if (isset($values[$node->nodeName]) and is_array($values[$node->nodeName])) {
                                    $values[$node->nodeName][] = $attributes;
                                } else {
                                    $values[$node->nodeName] = $attributes;
                                }
                            }
                        }
                    } else {
                        if (empty($attributes)) {
                            $values[$node->nodeName] = $node->nodeValue;
                        } else {
                            $values[$node->nodeName] = ($node->nodeValue) ? array_merge(array($node->nodeValue), $attributes) : $attributes;
                        }
                    }
                }
            } else if ($node instanceof DOMAttr) {
                if (! array_key_exists($node->name, $values)) {
                    $values[$node->name] = $node->value;
                } else {
                    if (! is_array($values[$node->name])) {
                        $values[$node->name] = array($values[$node->name]);
                    }

                    if (is_array($values[$node->name])) {
                        $values[$node->name][] = $node->value;
                    } else {
                        $values[$node->name] = array($node->value);
                    }
                }
            }
        }

        return $values;
    }
1173647
public function getElement(\DOMElement $nodeList, $level = 0, $showPaths = false)
    {
        $tabs = str_repeat("\t", $level);
        $output = '';
        if (!$showPaths) {
            $output = "";
            foreach ($nodeList as $attribute) {
                $output .= $tabs . $attribute->nodeName . " = " . $attribute->nodeValue . "\n";
            }

            $output .= $tabs . $nodeList->nodeName . " = " . $nodeList->nodeValue . "\n";
        } else {
            $output .= $nodeList->getNodePath() . "\n";
        }

        foreach ($nodeList->childNodes as $childObject) {
            if ($childObject instanceof \DOMElement) {
                $output .= $this->getElement($childObject, $level + 1, $showPaths);
            } elseif ($showPaths) {
                $output .= $childObject->getNodePath() . "\n";
            }
        }

        return $output;
    }
173126
public function children(): NodeList {
        $results = $this->collection()->reduce(function($carry, $node) {
            return $carry->merge(
                $node->findXPath('child::*')
            );
        }, $this->newNodeList());

        return $results;
    }
942854
private function getRelatedObjectList( DOMNodeList $domNodeList )
    {
        $embeddedObjectIdArray = array();
        foreach( $domNodeList as $embed )
        {
            if ( $embed->hasAttribute( 'object_id' ) )
            {
                $embeddedObjectIdArray[] = $embed->getAttribute( 'object_id' );
            }
            elseif ( $embed->hasAttribute( 'node_id' ) )
            {
                if ( $object = eZContentObject::fetchByNodeID( $embed->getAttribute( 'node_id' ) ) )
                {
                    $embeddedObjectIdArray[] = $object->attribute( 'id' );
                }
            }
        }
        return $embeddedObjectIdArray;
    }
255547
protected function addToQueue($nodeList) {
    for ($i=sizeof($nodeList)-1; $i>=0; $i--) {
      if ($nodeList[$i] instanceof Node) {
        $this->nodeList[] = $nodeList[$i];
      }
    }
  }
351638
public function contents(): NodeList {
        $results = $this->collection()->reduce(function($carry, $node) {
            if ($node->isRemoved()) {
                return $carry;
            }

            return $carry->merge(
                $node->newNodeList($node->childNodes)
            );
        }, $this->newNodeList());

        return $results;
    }
189519
protected function exportNodeDataList(array &$nodeDataList)
    {
        $this->xmlWriter->startElement('nodes');
        $this->xmlWriter->writeAttribute('formatVersion', self::SUPPORTED_FORMAT_VERSION);

        $nodesStack = [];
        foreach ($nodeDataList as $nodeData) {
            $this->exportNodeData($nodeData, $nodesStack);
        }

        // Close remaining <node> tags according to the stack:
        while (array_pop($nodesStack)) {
            $this->xmlWriter->endElement();
        }

        $this->xmlWriter->endElement();
    }
1305467
function(nodeList){
			var last = nodeList[nodeList.length - 1];
			// If the last node in the list is not an HTMLElement
			// it is a nodeList so call `last` again.
			if(last.nodeType) {
				return last;
			} else {
				return nodeLists.last(last);
			}
		}
107592
protected function nodesFromHtml($html): NodeList {
        $class = get_class($this->document());
        $doc = new $class();
        $nodes = $doc->html($html)->find('body > *');

        return $nodes;
    }
500746
public function mapTree( $modelList )
	{
		$tree = $modelList instanceof Arrayable ? $modelList->toArray() : $modelList;

		$affectedKeys = [];

		$result = $this->mapTreeRecursive( $tree, $this->model->getKey(), $affectedKeys );

		if ( $result && count( $affectedKeys ) > 0 )
			$this->deleteUnaffected( $affectedKeys );

		return $result;
	}
598103
protected function fromArray(array $nodeArray)
    {

        $node = $this->nodeCreator->makeNode();

        $node->id = $nodeArray['id'];
        $node->setPath($nodeArray['path']);
        $node->setMenuTitle($nodeArray['menu_title']);
        $node->setTitle($nodeArray['title']);
        $node->setContent($nodeArray['content']);
        $node->parent_id = 'parent-id-'.$nodeArray['id'];
        $node->route_name = $nodeArray['routeName'];

        return $node;

    }
816945
public void logDomNodeList (String msg, NodeList nodeList) {
		StackTraceElement caller = StackTraceUtils.getCallerStackTraceElement ();

		String toLog = (msg != null ? msg + "\n" : "DOM nodelist:\n");
		for (int i = 0; i < nodeList.getLength (); i++) {
			toLog += domNodeDescription (nodeList.item (i), 0) + "\n";
		}

		if (caller != null) {
			logger.logp (Level.FINER, caller.getClassName (), caller.getMethodName () + "():" + caller.getLineNumber (), toLog);
		} else {
			logger.logp (Level.FINER, "(UnknownSourceClass)", "(unknownSourceMethod)", toLog);
		}
	}
898766
public static function fromXml(\DOMNodeList $xml)
    {
        $items = array();
        foreach ($xml as $xmlTag) {
            $items[] = Loan::fromXml($xmlTag);
        }
        return new static($items);
    }