All pastes #594557 Raw Edit

Something

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

error_reporting(E_ALL);
function RecurseXML($xml,$parent="")
{
$sql = "INSERT INTO SHIT 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");      
			$sql.="{$key}='{$value}', ";
			//return $sql;
			
	      }
	   }     
   }
   
   //echo $sql;
   //$sql='test';
   return array($child_count, $sql);
   
}
$xml = simplexml_load_file('test2.xml');

$test = RecurseXML($xml);
//	echo $test;

print_r($test);



?>