PHP SimpleXML + Get Attribute

XML, который я читаю, выглядит так:

<show id="8511">

    <name>The Big Bang Theory</name>
    <link>http://www.tvrage.com/The_Big_Bang_Theory</link>
    <started>2007-09-24</started>
    <country>USA</country>

    <latestepisode>
        <number>05x23</number>
        <title>The Launch Acceleration</title>
    </latestepisode>

</show>

Чтобы получить (например) номер последнего эпизода, я бы сделал:

$ep = $xml->latestepisode[0]->number;

Это прекрасно работает. Но что мне сделать, чтобы получить идентификатор из ?

Я пробовал что-то вроде:

$id = $xml->show;
$id = $xml->show[0];

Но ничего не помогло.

Обновление

Мой фрагмент кода:

$url    = "http://services.tvrage.com/feeds/episodeinfo.php?show=".$showName;
$result = file_get_contents($url);
$xml = new SimpleXMLElement($result);

//still doesnt work
$id = $xml->show->attributes()->id;

$ep = $xml->latestepisode[0]->number;

echo ($id);

Ori. XML:

http://services.tvrage.com/feeds/episodeinfo.php?show=The.Big.Bang.Theory
18
задан r0skar 10 May 2012 в 15:56
поделиться