Parses a collection of "option" XML nodes.

@param \SimpleXMLElement $nodes The XML nodes

@return array The options
541892
protected function parseOptions(\SimpleXMLElement $node)
    {
        $options = [];
        /** @var \SimpleXMLElement $option */
        foreach ($node->option as $option) {
            if ($option->count() > 0) {
                if (count($option->value) > 0) {
                    $value = $this->parseValues($option);
                } else {
                    $value = [];
                }
            } else {
                $value = XmlUtils::phpize($option);
                if (is_string($value)) {
                    $value = trim($value);
                }
            }

            $options[(string) $option['name']] = $value;
        }

        return $options;
    }
586993
public function getListNodes($nodes)
    {
        $xPath = new DOMXPath($this->getDomXml());
        $nodeList = $xPath->query("//SUBMENU[@cl='" . implode("' or @cl='", $nodes) . "']");

        return ($nodeList->length) ? $nodeList : null;
    }
1041254
public function setNodes(ArrayCollection $nodes)
    {
        $finalNodes = array();

        foreach ($nodes as $node) {
            if ($this->checkChildNode($node)) {
                $node->setParent($this);
                $finalNodes[] = $node;
            }
        }

        $this->nodes = $finalNodes;

        return $this;
    }
354579
protected function simpleXmlToArray(SimpleXMLElement $xml) {
		$result = [];
		
		foreach ($xml as $element) {
			$name    = $element->getName();
			$content = get_object_vars($element);
			
			if (isset($content['@attributes'])){
				if (isset($content['@attributes']['value'])) {
					$result[$name] = Std::parseValue($content['@attributes']['value']);
					continue;
				}
				
				unset($content['@attributes']);
			}
			
			if (empty($content)) {
				$result[$name] = Std::parseValue($element);
				continue;
			}
			
			$result[$name] = $this->simpleXmlToArray($element);
		}
		
		return $result;
	}
204055
protected function getHierarchicalChoices($nodes, $depth = 0)
    {
        $choices = array();
        foreach ($nodes as $node) {
            $choices[$node['node']['nodeId']] = $node['node']['name'];
            if (array_key_exists('child', $node)) {
                $choices = array_merge($choices, $this->getHierarchicalChoices($node['child'], $depth + 1));
            }
        }

        return $choices;

    }
225915
private function processNode(\SimpleXMLElement $node): array
    {
        $config = [];
        foreach ($node as $name => $value) {
            if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) {
                $name = $matches[1];
            }
            if ($value->count() > 0) {
                $config[$name] = $this->processNode($value->children());
            } else {
                $value = (string)$value;
                $config[$name] = $value;

                if (\preg_match('/^[0-9]+$/', $value)) {
                    $config[$name] = (int)$value;
                } elseif (\preg_match('/^[0-9\.]+$/', $value)) {
                    $config[$name] = (float)$value;
                } elseif (\preg_match('/^true|false$/', $value)) {
                    $config[$name] = $value === 'true' ? true : false;
                }
            }
        }
        return $config;
    }
1119413
protected function parseValues(\SimpleXMLElement $nodes)
    {
        $values = [];

        foreach ($nodes as $node) {
            if (\count($node) > 0) {
                if (\count($node->value) > 0) {
                    $value = $this->parseValues($node->value);
                } elseif (\count($node->constraint) > 0) {
                    $value = $this->parseConstraints($node->constraint);
                } else {
                    $value = [];
                }
            } else {
                $value = trim($node);
            }

            if (isset($node['key'])) {
                $values[(string) $node['key']] = $value;
            } else {
                $values[] = $value;
            }
        }

        return $values;
    }
419310
private function _getTreeNodesIds($nodes)
    {
        $result = [];

        foreach ($nodes as $node) {
            $result[] = $node->id;
        }

        return $result;
    }
172368
public static function parseElementXml(SimpleXMLElement $xml){

        $attributes = array();
        foreach($xml->attributes() as $name => $value){
            $attributes[$name] = (string) $value;
        }

        $returnValue = array(
            'qtiClass' => $xml->getName()
        );

        if(count($attributes)){
            $returnValue['attributes'] = $attributes;
        }

        return $returnValue;
    }
1079791
private function parseElementNodes($children, $parentName = null)
    {
        $result = [];

        foreach ($children as $child) {
            $prefix = $child->prefix ?: null;
            $oname  = $this->normalizeKey($child->nodeName);
            $name   = $this->prefixKey($oname, $prefix);

            if (isset($result[$name])) {
                $this->parseSetResultNodes($child, $name, $result);
                continue;
            }

            $this->parseUnsetResultNodes($child, $name, $oname, $parentName, $result, $prefix);
        }

        return $result;
    }
1104449
public static function parse(\SimpleXMLElement $node)
	{
		if ($node->getName() != self::$tagName) {
			return null;
		}

		$bounds = new Bounds();

		$bounds->minLatitude = isset($node['minlat']) ? (float) $node['minlat'] : null;
		$bounds->minLongitude = isset($node['minlon']) ? (float) $node['minlon'] : null;
		$bounds->maxLatitude = isset($node['maxlat']) ? (float) $node['maxlat'] : null;
		$bounds->maxLongitude = isset($node['maxlon']) ? (float) $node['maxlon'] : null;

		return $bounds;
	}
1112385
public function parse( $xml )
	{
		$this->loadXml( $xml );
		$root	= $this->document->firstChild;
		while( $root->nodeType == XML_COMMENT_NODE )
			$root	= $root->nextSibling;

		$tree	= new XML_DOM_Node( $root->nodeName );
		if( $root->hasAttributes())
		{
			$attributeNodes	= $root->attributes;
			foreach( $attributeNodes as $attributeNode )
				$tree->setAttribute( $attributeNode->nodeName, $attributeNode->nodeValue );
		}
		$this->parseRecursive( $root, $tree );
		return $tree;
	}
694027
protected function handleOptions($xml, $options = [])
    {
        if ($xml instanceof \SimpleXMLElement) {
            foreach ($xml->children() as $name => $option) {
                $attributes = XmlHelper::getAttributes($option);

                $option = new Option((string) $option, XmlHelper::getAttribute($option, 'value'), $attributes);

                $this->options[] = $option;
            }
        } else {
            foreach ($options as $name => $option) {
                if (!($option instanceof Option)) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'Please give me %s class as option, %s given.',
                            Option::class,
                            get_class($option)
                        )
                    );
                }

                if (is_numeric($name)) {
                    $this->options[] = $option;
                } else {
                    $this->options[$name] = $option;
                }
            }
        }
    }
568341
protected function &getOptions()
    {
        $options = array();

        foreach ($this->tree->getChildren() as $child_node) {
            $this->flattenTree($options, $child_node);
        }

        return $options;
    }
1331937
private function buildArrayFromNode(SimpleXMLElement $node): array
    {
        $array = [];
        foreach ($node->children() as $child) {
            if ((string) $child !== '') {
                $array[] = (string) $child;
            }
        }

        return $array;
    }
376027
protected static function getRssItems(\SimpleXMLElement $items)
    {
        $rssItems = [];

        $namespaces = $items->getNamespaces(true);

        foreach ($items as $item) {
            $rssItem = [
                'url' => null,
                'originUrl' => null,
                'pubdate' => null,
            ];

            $rssItem['url'] = (string) $item->link;
            $rssItem['originUrl'] = ((string) $item->origLink ?: (string) $item->comments);
            $rssItem['pubdate'] = ((string) $item->pubdate ?: (string) $item->pubDate);

            if (!$rssItem['pubdate'] && isset($namespaces['dc']) && ($children = $item->children($namespaces['dc']))) {
                $rssItem['pubdate'] = (string) $children->date;
            }

            if (!$rssItem['originUrl'] && isset($namespaces['feedburner']) && ($children = $item->children($namespaces['feedburner']))) {
                $rssItem['originUrl'] = (string) $children->origLink;
            }

            if ($rssItem['url']) {
                $rssItems[] = $rssItem;
            }
        }

        return $rssItems;
    }
260006
private function parseLogger(\SimpleXMLElement $node) {
		$logger = array();
		
		$name = $this->getAttributeValue($node, 'name');
		if (empty($name)) {
			$this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
			return;
		}
		
		if (isset($node->level)) {
			$logger['level'] = $this->getAttributeValue($node->level, 'value');
		}
		
		if (isset($node['additivity'])) {
			$logger['additivity'] = $this->getAttributeValue($node, 'additivity');
		}
		
		$logger['appenders'] = $this->parseAppenderReferences($node);

		// Check for duplicate loggers
		if (isset($this->config['loggers'][$name])) {
			$this->warn("Duplicate logger definition [$name]. Overwriting.");
		}
		
		$this->config['loggers'][$name] = $logger;
	}