fix support of Atom 0.3
This commit is contained in:
parent
32011b9b66
commit
a3b9fd12c5
|
@ -27,6 +27,7 @@ class FeedParser {
|
||||||
$root = $this->doc->firstChild;
|
$root = $this->doc->firstChild;
|
||||||
$xpath = new DOMXPath($this->doc);
|
$xpath = new DOMXPath($this->doc);
|
||||||
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
|
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
|
||||||
|
$xpath->registerNamespace('atom03', 'http://purl.org/atom/ns#');
|
||||||
$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
|
$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
|
||||||
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
||||||
$xpath->registerNamespace('slash', 'http://purl.org/rss/1.0/modules/slash/');
|
$xpath->registerNamespace('slash', 'http://purl.org/rss/1.0/modules/slash/');
|
||||||
|
@ -35,7 +36,7 @@ class FeedParser {
|
||||||
|
|
||||||
$this->xpath = $xpath;
|
$this->xpath = $xpath;
|
||||||
|
|
||||||
$root = $xpath->query("(//atom:feed|//channel|//rdf:rdf|//rdf:RDF)")->item(0);
|
$root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)")->item(0);
|
||||||
|
|
||||||
if ($root) {
|
if ($root) {
|
||||||
switch (mb_strtolower($root->tagName)) {
|
switch (mb_strtolower($root->tagName)) {
|
||||||
|
@ -60,18 +61,29 @@ class FeedParser {
|
||||||
|
|
||||||
$title = $xpath->query("//atom:feed/atom:title")->item(0);
|
$title = $xpath->query("//atom:feed/atom:title")->item(0);
|
||||||
|
|
||||||
|
if (!$title)
|
||||||
|
$title = $xpath->query("//atom03:feed/atom03:title")->item(0);
|
||||||
|
|
||||||
|
|
||||||
if ($title) {
|
if ($title) {
|
||||||
$this->title = $title->nodeValue;
|
$this->title = $title->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
|
$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
|
||||||
|
|
||||||
|
if (!$link)
|
||||||
|
$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
|
||||||
|
|
||||||
|
|
||||||
if ($link && $link->hasAttributes()) {
|
if ($link && $link->hasAttributes()) {
|
||||||
$this->link = $link->getAttribute("href");
|
$this->link = $link->getAttribute("href");
|
||||||
}
|
}
|
||||||
|
|
||||||
$articles = $xpath->query("//atom:entry");
|
$articles = $xpath->query("//atom:entry");
|
||||||
|
|
||||||
|
if (!$articles || $articles->length == 0)
|
||||||
|
$articles = $xpath->query("//atom03:entry");
|
||||||
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
|
array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue