Forum Moderators: coopster

Message Too Old, No Replies

Error message when parsing with simpleXML

simpleXML

         

nickesollentuna

1:33 pm on May 20, 2008 (gmt 0)

10+ Year Member



Hi there!
First of all I'm not a very experienced PHP-programmer so I need some help with this one. I'm parsing some xml with simpleXML and it works when I use loacalhost with XAMPP but not online. Online I get the errormessage below. I've checked and the xml-file is where it should be.
Doeas anyone have an idea why this is happening?

All the best, Niklas

Warning: file_get_contents() [function.file-get-contents]: Unable to access xml/liveText.xml in /customers/example.com/example.com/httpd.www/seo/datasource.php on line 9

Warning: file_get_contents(xml/liveText.xml) [function.file-get-contents]: failed to open stream: No such file or directory in /customers/example.com/example.com/httpd.www/seo/datasource.php on line 9

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /customers/example.com/example.com/httpd.www/seo/datasource.php:12 Stack trace: #0 /customers/example.com/example.com/httpd.www/seo/datasource.php(12): SimpleXMLElement->__construct('') #1 {main} thrown in /customers/example.com/example.com/httpd.www/seo/datasource.php on line 12

The simpleXML php code:
//Get
$xmlFileData = file_get_contents("xml/liveText.xml");

//Simple XML parser
$xmlData = new SimpleXMLElement($xmlFileData);

$xmlPara = $xmlData->page->text;

//The output
print($xmlPara);

[1][edited by: jatar_k at 2:01 pm (utc) on May 20, 2008]
[edit reason] please use example.com [/edit]

eelixduppy

7:05 pm on May 20, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld!

It seems to be having a problem finding the file at one point. check the path and if it still doesn't work, try using the full path. Also check the permissions of the XML file to see if you can access it correctly.

nickesollentuna

11:17 am on May 21, 2008 (gmt 0)

10+ Year Member



Thanks for the reply!
Hmmm...
I've tried the full path to the XML - but still the same problem.
What permission do you think I would need?
Right now it's set to 755 for the xml-file.

All the best, Niklas