PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jun 19, 2018 8:30 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Cannot read XML file
PostPosted: Wed Jan 31, 2018 10:41 am 
Offline
Forum Newbie

Joined: Wed Jan 31, 2018 10:36 am
Posts: 1
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


Top
 Profile  
 
 Post subject: Re: Cannot read XML file
PostPosted: Wed Jan 31, 2018 11:46 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13561
Location: New York, NY, US
Where is the file "Stations.xml"? The could should probably be:
Syntax: [ Download ] [ Hide ]
simplexml_load_file('/full/file_system/path/to/Stations.xml');
* replace '/full/file_system/path/to/' with the actual path to the directory containing the XML file.

_________________
(#10850)


Top
 Profile  
 
 Post subject: Re: Cannot read XML file
PostPosted: Tue Feb 06, 2018 2:48 am 
Offline
Forum Newbie

Joined: Tue Feb 06, 2018 2:33 am
Posts: 5
<?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.');
}
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group