Link to home
Start Free TrialLog in
Avatar of Mutsop
MutsopFlag for Belgium

asked on

non-object and invalid argument

Hi,

I have a problem with reading an xml file... and am not sure why I'm getting the error.
So here is a part of the xml:

<status>
<shard name="Blightweald" online="True" locked="False" population="high" queued="0" language="English" pvp="False" rp="False" recommend="False"/>
<shard name="Cloudborne" online="True" locked="False" population="high" queued="0" language="English" pvp="True" rp="False" recommend="False"/>
<shard name="Steampike" online="True" locked="False" population="high" queued="0" language="English" pvp="False" rp="False" recommend="False"/>
</status>

Open in new window



and here is my code:
$url = "http://eu.riftgame.com/en/status/eu-status.xml";

		// READ THE EXTERNAL DATA
		$xml = simplexml_load_file($url);

		foreach ($xml->status["shard"] as $shard)
		{
			if ($shard["name"] == "Blightweald")
			{
				echo $shard->name;
				echo $shard->population;
			}
		}

Open in new window


I even tried setting
$xml->status["shard"]

to

$xml->status->shard

But no use. That would be an invalid argument.

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of zappafan2k2
zappafan2k2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mutsop

ASKER

Oh okay... Well I thought the root had to be set too :)
Thanks, it works like a charm
Avatar of Mutsop

ASKER

thanks