Petr Novák
Petr Novák

Reputation: 115

php simplexml_load_file and null variable

I have this very simple php code:

$xml=simplexml_load_file('abc.xml'); echo $xml;

It shows only blank page, no characters, nothing... Why? Does simplexml_load_file work correctly?

Upvotes: 0

Views: 493

Answers (1)

koopajah
koopajah

Reputation: 25622

$xml is an object. You can "visualize" it with

var_dump($xml);

You should read the examples section on simplexml in the PHP documentation : http://php.net/manual/en/simplexml.examples-basic.php to understand how to display specific nodes information.

If you want to display the content of your xml directly you can do this :

//output xml in your response:
header('Content-Type: text/xml');
echo $xml->asXML(); 

Upvotes: 1

Related Questions