I'm trying to make a php script to upload an xml file to mysql. I got it to parse the file and show it on the page.
<?
$file = "$form_data";
function contents($parser, $data){
echo $data;
}
function startTag($parser, $data){
echo "<b>";
}
function endTag($parser, $data){
echo "</b>";
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_parser, "contents");
$fp = fopen($file, "r");
$data = fread($fp, 80000);
if(!(xml_parse($xml_parser, $data, feof($fp)))){
die("Error on line " . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser);
fclose($fp);
?>
Now what i need to do is select the name field from the XML file and insert that into a database called test. Ive tried using load XML local infile and other methods but I cant get anything to work.