Jump to content

SimpleXMLElement Issue


Solarpitch

Recommended Posts

Hi Guys,

 

I'm trying to run the following code but the page breaks with no errors. I'm using PHP 5 which should run Simple XML. Code seems fine to me...

 

<?php
$xmlstr = "courses.xml";
$xml = new SimpleXMLElement($xmlstr); //  I Know it's breaking at this line

echo $xml->course[0]->name;
?>

Link to comment
https://forums.phpfreaks.com/topic/237885-simplexmlelement-issue/
Share on other sites

php doesn't just stop running or "breaking" as you say, without a reason (without an error).  If it is because of an error, you must have error reporting turned off in php.ini or .htaccess or somewhere. 

 

edit: also, are you sure that 3rd line of code is even returning anything?

 

 

Ok, got the error..

 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php on line 50

 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://site.mysite.ie/wp-content/themes/iact/courses.xml in /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php on line 50

 

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php on line 50

 

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php:50 Stack trace: #0 /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php(50): SimpleXMLElement->__construct('http://site.iac...') #1 /var/www/vhosts/httpdocs/wp-includes/template-loader.php(43): include('/var/www/vhosts...') #2 /var/www/vhosts/httpdocs/wp-blog-header.php(16): require_once('/var/www/vhosts...') #3 /var/www/vhosts/httpdocs/index.php(17): require('/var/www/vhosts...') #4 {main} thrown in /var/www/vhosts/httpdocs/wp-content/themes/iact/page.php on line 50

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.