pour l'instant ce que j'ai fait mais ca marche pas
<?php
$Tagcourrant="";
$prendre="";
$title="";
$valeurs=array();
function bo($parser, $name, $attributes)
{
global $tagcourant;
$tagcourant = $name;
if(tagcourant==value)
$prendre=1;
else $prendre =0;
}
function bf($parser, $name)
{
if($title=aliascpu and $tagcourant=value){
$query = "INSERT INTO cpu";
$query .= "(typecpu,aliascpu)";
$query .= "VALUES(\"" . join("\", \"", $values) ."\" );";
echo $query;
$values = array();
$currentTag = "";
}
}
function datafuntion($parser, $data)
{
$data=chop($data);
$data=trim($data);
global $Tagcourrant, $values , $title ;
switch($data)
{
case 'Type de processeur':$title=pcpu;
break;
case 'Alias du CPU':$title="aliascpu";
break;
}
if($prendre==1)
array_push($valeurs,$data);
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "bo", "bf" );
xml_set_character_data_handler($xml_parser, "datafunction" );
if (!($fp = fopen("test.xml", "r" )))
{
die("File I/O error: test.xml" );
}
while ($data = fread($fp, filesize("test.xml" )))
{
// error handler
if (!xml_parse($xml_parser, $data, feof($fp)))
{
$error_code = xml_get_error_code($xml_parser);
die("XML parser error (error code " . $error_code . " ): " . xml_error_string($error_code) . "<br>Error occurred at line " . xml_get_current_line_number($xml_parser));
}
}
xml_parser_free($xml_parser);
fclose($fp);
echo "Traitement réussi";
?>