children() as $child) { // Get the 1st level child foreach ($child->children() as $level_one) { if ($level_one->children()) { // Get the 2nd level child foreach ($level_one->children() as $level_two) { if ($level_two->children()) { // Get the 3rd level child foreach ($level_two->children() as $level_three) { array_push($rsp, "$level_three"); } } else { array_push($rsp, "$level_two"); } } } else { array_push($rsp, "$level_one"); } } } } // Reply in the form of JSON $rtn = array("rsp" => $rsp, "msg" => $msg); echo json_encode($rtn); } /** * Extract the output for a webrun command * * @param $xml The XML output from docmd() * @return An array containing the output */ function extractWebrun($xml) { $rsp = array(); $i = 0; // Extract data returned foreach($xml->children() as $nodes){ foreach($nodes->children() as $node){ // Get the node name $name = $node->name; // Get the content $status = $node->data->contents; // Add to return array $rsp[$i] = array("$name", "$status"); $i++; } } return $rsp; } /** * Extract the output for a extnoderange command * * @param $xml The XML output from docmd() * @return The nodes and groups */ function extractExtnoderange($xml) { $rsp = array(); // Extract data returned foreach ($xml->xcatresponse->intersectinggroups as $group) { array_push($rsp, "$group"); } return $rsp; } ?>