I am trying to Insert data from XML to MySql.
So far i have written this: ?php
$servername = "localhost";
$username = "root";
$password = "rootuser";
$dbname = "my_data";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$string = file_get_contents('rss.xml');
$xml = new SimpleXMLElement($string);
echo 'All Values of a Group: -';
foreach($xml->system->system as $item){
echo $item->MY_Name.' - ';
echo $item->Version.' - ';
echo '<br/>';
mysqli_query($conn, "INSERT INTO customer_data_table (My_Name, Version ) VALUES (". $item->My_Name.", '". $item->Version."')" );
}
?
Any help is appreciated.