src/Helpers/XMLParser.php
function getchildren($vals, &$i)
    {
        $children = array();     // Contains node data
        // Node has CDATA before it's children
        if ($i > -1 && isset($vals[$i]['value'])) {
            $children['VALUE'] = $vals[$i]['value'];
        }

        // Loop through children, until hit close tag or run out of tags
        while (++$i < count($vals)) {

            $type = $vals[$i]['type'];

            // 'cdata':	Node has CDATA after one of it's children
            // 		(Add to cdata found before in this case)
            if ($type === 'cdata')
                $children['VALUE'] .= $vals[$i]['value'];

            // 'complete':	At end of current branch
            // 'open':	Node has children, recurse
            elseif ($type === 'complete' || $type === 'open') {
                $tag = $this->buildtag($vals[$i], $vals, $i, $type);
                if ($this->index_numeric) {
                    $tag['TAG'] = $vals[$i]['tag'];
                    $children[] = $tag;
                } else {
                    $children[$vals[$i]['tag']][] = $tag;
                }
            } elseif ($type === 'close') {
                // 'close:	End of node, return collected data
                //		Do not increment $i or nodes disappear!
                break;
            }
        }
        if ($this->collapse_dups) {
            foreach ($children as $key => $value) {
                if (is_array($value) && (count($value) == 1)) {
                    $children[$key] = $value[0];
                }
            }
        }
        return $children;
    }
function getchildren($vals, &$i)
    {
        $children = array();     // Contains node data
        // Node has CDATA before it's children
        if ($i > -1 && isset($vals[$i]['value'])) {
            $children['VALUE'] = $vals[$i]['value'];
        }

        // Loop through children, until hit close tag or run out of tags
        while (++$i < count($vals)) {

            $type = $vals[$i]['type'];

            // 'cdata':	Node has CDATA after one of it's children
            // 		(Add to cdata found before in this case)
            if ($type === 'cdata')
                $children['VALUE'] .= $vals[$i]['value'];

            // 'complete':	At end of current branch
            // 'open':	Node has children, recurse
            elseif ($type === 'complete' || $type === 'open') {
                $tag = $this->buildtag($vals[$i], $vals, $i, $type);
                if ($this->index_numeric) {
                    $tag['TAG'] = $vals[$i]['tag'];
                    $children[] = $tag;
                } else {
                    $children[$vals[$i]['tag']][] = $tag;
                }
            } elseif ($type === 'close') {
                // 'close:	End of node, return collected data
                //		Do not increment $i or nodes disappear!
                break;
            }
        }
        if ($this->collapse_dups) {
            foreach ($children as $key => $value) {
                if (is_array($value) && (count($value) == 1)) {
                    $children[$key] = $value[0];
                }
            }
        }
        return $children;
    }
internal function: build an nested array representing children