Jump to content

[SOLVED] No Error and No Output?


Beasts

Recommended Posts

hi,

i am using simplexml to load data from an xml file.

my php code is as follows :

				$xmldx = simplexml_load_string(file_get_contents('htmldata.xml'));
				$page = $xmldx->pages->home;
				echo($page);

 

simplexml_load_file() doesn't work either...

 

the xml is :

<?xml version="1.0" encoding="ISO-8859-1"?>
<pages>
<home>
asdasd
	<![CDATA[
                      <h1>THIS IS THE HOMEPAGE</h1>
	]]>
</home>
</pages>

 

my php settings are set to display all errors...

this code gives no error and no output?

Link to comment
https://forums.phpfreaks.com/topic/159113-solved-no-error-and-no-output/
Share on other sites

Use this (the pages tag is the document root tag and are not referenced to access the tags within it) -

 

$page = $xmldx->home;

 

Edit: It often helps to print out the xml object (at any level you are currently accessing it at) to see what it contains -

 

echo "<pre>",print_r($xmldx,true),"</pre>";

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.