xpath('child::node()'); //print_r($children); function RecurseXML($xml,$parent="") { //$sql="INSERT INTO tournaments SET "; $child_count = 0; foreach($xml as $key=>$value) { $child_count++; if(RecurseXML($value,$parent.".".$key) == 0) // no childern, aka "leaf node" { if ($parent==".Tournament"){ //print($parent . "." . (string)$key . " = " . (string)$value . "
\n"); //print((string)$key . " = " . (string)$value . "
\n"); echo "{$key}={$value}, "; //$sql.="{$key}='{$value}'"; } } } //echo $sql; return $child_count; } echo "INSERT INTO TABLE SET "; RecurseXML($xml); ?>