children() as $child) { foreach ($child->children() as $data) { if($data->name) { $node = $data->name; $cont = $data->data->contents; $cont = str_replace(":|:", "\n", $cont); array_push($rsp, "$node: $cont"); } else if(strlen("$data") > 2) { $data = str_replace(":|:", "\n", $data); array_push($rsp, "$data"); } } } } // 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; $status = str_replace(":|:", "\n", $status); // 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; } ?>