I have a php file called from html page. this file need to read a local xml file and return an array with data...
I tried many version of code but when i tried to open the file the page go in error without the possibility to check the error. The only command that work is $xml_string= file_get_contents('Stations.xml');
Any other like :
simplexml_load_string($xml_string);
simplexml_load_file("Stations.xml");
does not work...
The flag allow_open_url is ON...
Someone have an idea about what is happened...
Thanks in advance
Cannot read XML file
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Cannot read XML file
Where is the file "Stations.xml"? The could should probably be:* replace '/full/file_system/path/to/' with the actual path to the directory containing the XML file.
Code: Select all
simplexml_load_file('/full/file_system/path/to/Stations.xml');(#10850)
-
pardeeptrivedi
- Forum Newbie
- Posts: 5
- Joined: Tue Feb 06, 2018 1:33 am
Re: Cannot read XML file
<?php
// The file test.xml contains an XML document with a root element
// and at least an element /[root]/title.
if (file_exists('test.xml')) {
$xml = simplexml_load_file('test.xml');
print_r($xml);
} else {
exit('Failed to open test.xml.');
}
?>
// The file test.xml contains an XML document with a root element
// and at least an element /[root]/title.
if (file_exists('test.xml')) {
$xml = simplexml_load_file('test.xml');
print_r($xml);
} else {
exit('Failed to open test.xml.');
}
?>