Mutsop
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:
and here is my code:
I even tried setting
$xml->status["shard"]
to
$xml->status->shard
But no use. That would be an invalid argument.
Any ideas?
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>
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;
}
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
Thanks, it works like a charm