SimpleXMLElement Object ( [data] => Array ( [0] => hv8plus01.ppd.pok.ibm.com-summary: [1] => PctTotalTimeUser [2] => Wed Sep 9 23:20:00 2009 0.0090 [3] => Wed Sep 9 23:21:00 2009 0.0097 [4] => Wed Sep 9 23:22:00 2009 0.0081 [5] => Wed Sep 9 23:23:00 2009 0.0081 [6] => Wed Sep 9 23:24:00 2009 0.0072 ) ) ) */ $index = 0; echo "[{label: \"$attr\", data: ["; foreach ($xml->children() as $response) foreach($response->children() as $data) { //remove the first 2 lines. if($index++ < 2) { continue; } //then, parse "date" & "value" $arr = preg_split("/\s+/", $data); array_pop($arr); $val = array_pop($arr); $time = implode(" ", $arr); $timestamp = strtotime($time); $timestamp .="000"; if($index++==2) { echo "[$timestamp,$val]"; } else { echo ",[$timestamp,$val]"; } } echo "]}]"; //echo <<