Ik probeer met SimpleXML o.a. een RSS 1.0-feed uit te lezen. Voor het gemak, hier is de feed:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel rdf:about="http://example.com/news.rss">
<title>Example Channel</title>
<link>http://example.com/</link>
<description>My example channel</description>
<items>
<rdf:Seq>
<rdf:li resource="http://example.com/2002/09/01/"/>
<rdf:li resource="http://example.com/2002/09/02/"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="http://example.com/2002/09/01/">
<title>News for September the First</title>
<link>http://example.com/2002/09/01/</link>
<description>other things happened today</description>
<dc:date>2002-09-01</dc:date>
</item>
<item rdf:about="http://example.com/2002/09/02/">
<title>News for September the Second</title>
<link>http://example.com/2002/09/02/</link>
<dc:date>2002-09-02</dc:date>
</item>
</rdf:RDF>
In de channel-tag staan items die je kunt combineren met de item-tags die na de channnel-tag komen. Dus de eerste "rdf:li" hoort bij het eerste item na de channel-tag.
Nu wil ik die 2 combineren, alleen pakt SimpleXML op de een of andere manier de dubbelepuntjes niet. Wat ik doe is dit:
<?php
$sxe = new SimpleXMLElement($res);
// En ik probeer op deze manier de items op te zoeken:
echo $sxe->channel->items->rdf:Seq->rdf:li[$i]->attributes()->resource
?>
Toen dat niet werkte keek ik eens met var_dump wat PHP er van maakte:
object(SimpleXMLElement)#1 (2) {
["channel"]=> object(SimpleXMLElement)#2 (4) {
["title"] => string(15) "Example Channel"
["link"] => string(19) "http://example.com/"
["description"] => string(18) "My example channel"
["items"] => object(SimpleXMLElement)#5 (0) {
}
}
["item"]=> array(2) {
[0]=> object(SimpleXMLElement)#3 (3) {
["title"]=> string(28) "News for September the First"
["link"]=> string(30) "http://example.com/2002/09/01/"
["description"]=> string(27) "other things happened today"
}
[1]=> object(SimpleXMLElement)#4 (2) {
["title"]=> string(29) "News for September the Second"
["link"]=> string(30) "http://example.com/2002/09/02/"
}
}
}
En zoals je ziet is er geen enkel item in de channel-tag.
Weet iemand hoe ik die items er wel in kan krijgen?