Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $xml=simplexml_load_file("demo_xml.xml") or die("Error: Cannot create object"); // get object
- //echo '<pre>';
- //print_r($xml);
- //echo '</pre>';
- $path = "demo_xml.xml";
- $file_get = file_get_contents($path);
- $load = simplexml_load_string($file_get);
- $get_json = json_encode($load);
- $result = json_decode($get_json, true);
- //
- //foreach ($result as $item) {
- //
- // foreach ($item as $value) {
- //
- // foreach ($value as $items) {
- //
- // foreach ($items as $get_item) {
- // echo '<pre>';
- // print_r($get_item[0]);
- // echo '</pre>';
- // }
- //
- // }
- //
- //
- // }
- //
- //}
- //$servername = "localhost";
- //$username = "frodo";
- //$password = "qwerty";
- //$dbname = "xml_db";
- //
- //
- //$conn = new mysqli($servername, $username, $password, $dbname);
- //
- //if ($conn->connect_error) {
- // die("Connection failed: " . $conn->connect_error);
- //}
- //
- //
- //$sql = "CREATE TABLE xml (
- //room_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- //hotel_caption VARCHAR(30) NOT NULL,
- //room_caption VARCHAR(30) NOT NULL,
- //price DECIMAL (50),
- //)";
- //
- //if ($conn->query($sql) === TRUE) {
- // echo "Ok";
- //} else {
- // echo "Error" . $conn->error;
- //}
- //$conn->close();
- foreach ($xml->children() as $item) {
- foreach ($item->children() as $value) {
- foreach ($value->children() as $child) {
- echo $child->getName(). ": " . $child . "<br />";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement