CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 PHP XML Parser into .sql file

Print topic Send  topic

Author Message
infobih

Posts: 58
Posted: 05/28/2008, 12:46 AM

Hi all

I need to do XML import in MySQL database. I have found this script and it reads and parse my XML file to display it in browser.

How can I modify code to write results into SQL style format file with INSERT statements...

Thanks

  
  
<?php  
  
$file = "sodim.xml";  
  
function contents($parser, $data){  
echo $data;  
}  
  
function startTag($parser, $data){  
echo "<b>";  
}  
  
function endTag($parser, $data){  
echo "</b><br />";  
}  
  
$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);  
  
?>   
  
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.