0

I have a local xml file which I am trying to display over a webpage with following code.

All I get is a blank page.

enter code here

<?php
   $xml_content = file_get_contents("C:\Users\user\Downloads\93D7.xml");
   $data = simplexml_load_string($xml_content);
   foreach ($data->item as $item) {
      var_dump($item->bookname);
   }
?>

Once the display works, I want to have a drop down where I will select the xml element / entity and it will display the value or child of that element / entity.

Can someone help?

I referred : Get multiple items from XML with SimpleXML & populating dropdown with values from xml file in php

Both individually gives me a blank page.

pedrohreis
  • 1,030
  • 2
  • 14
  • 33
  • are you running the code with `display_errors = on` ? You should refer to this to see how you can find possible issues in your code: https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – Cornel Raiu Nov 11 '19 at 22:03
  • Yes, display_errors=on in php.ini. – 7strings Nov 12 '19 at 10:56
  • Do a var_dump or similar of the $xml_content right after you load the contents to see if it returns the content and then post the result please – Cornel Raiu Nov 12 '19 at 12:26
  • Good idea. Let me try that and get back to you. Though it loads fine on browser. – 7strings Nov 13 '19 at 08:02
  • Hi Cornel.Raiu, vardump just after loading works fine. It outputs the xml content, though with some different formatting. Like this: – 7strings Nov 13 '19 at 15:43
  • Hi Cornel.Raiu, vardump just after loading works fine. It outputs the xml content, though with some different formatting. With => deliminator in between elements. It is a huge file and therefore can not post the content here. – 7strings Nov 13 '19 at 15:50
  • and what do you get in `var_dump($data)`? – Cornel Raiu Nov 13 '19 at 16:21
  • These are the first few lines. Rest of the code looks the same. object(SimpleXMLElement)#1 (15) { ["@attributes"]=> array(1) { ["name"]=> string(4) "User" } ["overview"]=> object(SimpleXMLElement)#2 (11) { ["permission"]=> string(4) "Full " ["LoginID"]=> object(SimpleXMLElement)#16 (0) { } ["User creation"]=> string(21) "06:07:2016 - 00:01:46" – 7strings Nov 13 '19 at 16:58

0 Answers0