<?php
//$str = file_get_contents("app.xml")
$xml = simplexml_load_file("app.xml");
$cnt = count($xml->state);
$res = mysql_connect("localhost",'root', '') or die(mysql_error());
mysql_select_db("yourdb") or die(mysql_error());
for($i=0;$i<=$cnt;$i++){
$countryName =mysql_escape_string($xml->state[$i]->name);
foreach($xml->state[$i]->attributes() as $a => $b)
{
//echo $a,'="',$b,"\"</br>";
//echo $b."<br>";
$countryId=$b;
}
echo "<br>".$sql ="INSERT INTO `yourtable` ( `country` , `country_short` ) VALUES ('$countryName', '$countryId' );";
mysql_query($sql) or die(mysql_error);
}
?>
Thursday, February 21, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment