XML, RSS and PHP simplexml

S

Skeets

given the following code:

<?xml version="1.0" encoding="utf-8" ?>
<rss version="0.91">
<config>
<status>exists</status>
</config>
</rss>

why is <rss version="0.91"></rss> required to get it to print out with
the following php code:

<?php
$s = simplexml_load_file('default/config.xml');
print $s->config->status . "\n";
?>

i've visited a few tutorials that didn't even mention rss and, of
course, their examples didn't work. the above code does work. remove
rss and it doesn't work.

how come?
 
M

Martin Honnen

Skeets wrote:

<?php
$s = simplexml_load_file('default/config.xml');
print $s->config->status . "\n";
?>

remove
rss and it doesn't work.

You need
$s->status
then I guess.
 
S

Skeets

martin, thanks, that worked. i guess there is no reason to call out
the doc level tag. i didn't pick this up from the tutorials i visited,
but that's probably my deficiency.

thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top