All pastes #594570 Raw Edit

Something

public text v1 · immutable
#594570 ·published 2007-06-29 00:18 UTC
rendered paste body
<? 

$xml = simplexml_load_file('test3.xml');

//$children = $xml->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 . "<BR>\n");  
         	//print((string)$key . " = " . (string)$value . "<BR>\n");      
         	echo "{$key}={$value}, ";
			//$sql.="{$key}='{$value}'";
         	
	      }
     
      }     
   }
   //echo $sql;
   return $child_count;
}

echo "INSERT INTO TABLE SET ";
RecurseXML($xml);


?>