private function _addchild($child, SimpleXMLExtended $xml, &$positions)
    {
        foreach ($child as $key=>$value) {
            $xmlnode = $xml->addChild("Process");
            if (isset($value[0])) {
                array_push($positions, $value[0]);
                $xmlnode->addAttribute('PID', $value[0]);
                $parentid = array_search($value[1], $positions);
                $xmlnode->addAttribute('ParentID', $parentid);
                $xmlnode->addAttribute('PPID', $value[1]);
                if (!defined('PSI_PLUGIN_PS_MEMORY_USAGE') || (PSI_PLUGIN_PS_MEMORY_USAGE !== false)) {
                    $xmlnode->addAttribute('MemoryUsage', $value[2]);
                }
                if (!defined('PSI_PLUGIN_PS_CPU_USAGE') || (PSI_PLUGIN_PS_CPU_USAGE !== false)) {
                    $xmlnode->addAttribute('CPUUsage', $value[3]);
                }
                $xmlnode->addAttribute('Name', $value[4]);
                if ((PSI_OS !== 'WINNT') &&
                    ((($parentid === 1) && (!defined('PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED === false)))
                    || ((!defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false)) && ($value[4] === "[kthreadd]")))) {
                    $xmlnode->addAttribute('Expanded', 0);
                }
            }
            if (isset($value['childs'])) {
                $this->_addChild($value['childs'], $xml, $positions);
            }
        }

        return $xml;
    }
private function _addchild($child, SimpleXMLExtended $xml, &$positions)
    {
        foreach ($child as $key=>$value) {
            $xmlnode = $xml->addChild("Process");
            if (isset($value[0])) {
                array_push($positions, $value[0]);
                $xmlnode->addAttribute('PID', $value[0]);
                $parentid = array_search($value[1], $positions);
                $xmlnode->addAttribute('ParentID', $parentid);
                $xmlnode->addAttribute('PPID', $value[1]);
                if (!defined('PSI_PLUGIN_PS_MEMORY_USAGE') || (PSI_PLUGIN_PS_MEMORY_USAGE !== false)) {
                    $xmlnode->addAttribute('MemoryUsage', $value[2]);
                }
                if (!defined('PSI_PLUGIN_PS_CPU_USAGE') || (PSI_PLUGIN_PS_CPU_USAGE !== false)) {
                    $xmlnode->addAttribute('CPUUsage', $value[3]);
                }
                $xmlnode->addAttribute('Name', $value[4]);
                if ((PSI_OS !== 'WINNT') &&
                    ((($parentid === 1) && (!defined('PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED === false)))
                    || ((!defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') || (PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false)) && ($value[4] === "[kthreadd]")))) {
                    $xmlnode->addAttribute('Expanded', 0);
                }
            }
            if (isset($value['childs'])) {
                $this->_addChild($value['childs'], $xml, $positions);
            }
        }

        return $xml;
    }
private function _addchild ( $ child , SimpleXMLExtended $ xml , & $ positions ) { foreach ( $ child as $ key => $ value ) { $ xmlnode = $ xml -> addChild ( "Process" ) ; if ( isset ( $ value [ 0 ] ) ) { array_push ( $ positions , $ value [ 0 ] ) ; $ xmlnode -> addAttribute ( 'PID' , $ value [ 0 ] ) ; $ parentid = array_search ( $ value [ 1 ] , $ positions ) ; $ xmlnode -> addAttribute ( 'ParentID' , $ parentid ) ; $ xmlnode -> addAttribute ( 'PPID' , $ value [ 1 ] ) ; if ( ! defined ( 'PSI_PLUGIN_PS_MEMORY_USAGE' ) || ( PSI_PLUGIN_PS_MEMORY_USAGE !== false ) ) { $ xmlnode -> addAttribute ( 'MemoryUsage' , $ value [ 2 ] ) ; } if ( ! defined ( 'PSI_PLUGIN_PS_CPU_USAGE' ) || ( PSI_PLUGIN_PS_CPU_USAGE !== false ) ) { $ xmlnode -> addAttribute ( 'CPUUsage' , $ value [ 3 ] ) ; } $ xmlnode -> addAttribute ( 'Name' , $ value [ 4 ] ) ; if ( ( PSI_OS !== 'WINNT' ) && ( ( ( $ parentid === 1 ) && ( ! defined ( 'PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED' ) || ( PSI_PLUGIN_PS_SHOW_PID1CHILD_EXPANDED === false ) ) ) || ( ( ! defined ( 'PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED' ) || ( PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false ) ) && ( $ value [ 4 ] === "[kthreadd]" ) ) ) ) { $ xmlnode -> addAttribute ( 'Expanded' , 0 ) ; } } if ( isset ( $ value [ 'childs' ] ) ) { $ this -> _addChild ( $ value [ 'childs' ] , $ xml , $ positions ) ; } } return $ xml ; }
recursive function to allow appending child processes to a parent process

@param array             $child      part of the array which should be appended to the XML
@param SimpleXMLExtended $xml        XML-Object to which the array content is appended
@param array             &$positions array with parent positions in xml structure

@return SimpleXMLExtended Object with the appended array content
recursive function to allow appending child processes to a parent process