0

I have written simple code to get content from xml file to php.

$xml = simplexml_load_file("http://localhost/xml_load/test_xml.xml");
print_r($xml);

First time It has run successfully but right now it is giving me warning and not executing properly.

Warning: simplexml_load_file(http://localhost/xml_load/test_xml.xml) [function.simplexml-load-file]: failed to open stream: HTTP request failed! <?xml version="1.0" encoding="ISO-8859-1"?> in C:\xampp\htdocs\XML_load\load_file.php on line 2

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://localhost/xml_load/test_xml.xml" in C:\xampp\htdocs\XML_load\load_file.php on line 2
2
  • Check if the file exists now at the given location. It might have been modified by your code the first time that it loaded properly, which is now giving you issues. Commented Apr 3, 2012 at 12:28
  • Check the file is existing or not Commented Apr 3, 2012 at 12:28

1 Answer 1

1

No file found on your respective location. Now, either check if your file exist. However, do try to make your local path doesn't based over BASEURL. Add that path further like

$xml = simplexml_load_file("xml/files/myxml.xml"); // PATH TO YOUR FILE.
echo "<pre>"; print_r($xml); "</pre>";
Sign up to request clarification or add additional context in comments.

2 Comments

I dont want to pass physical path.My requirement is to get xml data from other url.
So, how it could recognize your localhost path to production environment? however, it shows that your file is missing the file. Follow this please [link](http://stackoverflow.com/a/9998960/1310324)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.