Skip to content

Commit

Permalink
Fix parsing for non-RSS feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronaxvig committed Aug 1, 2020
1 parent ceb7115 commit d9b504d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ function processFeed($feed_data, $fetch_url) {
}

if ($generatorNode) {
$generator = $xpath->query("//channel/generator")->item(0)->nodeValue;
$generatorUri = $xpath->query("//channel/generator")->item(0)->getAttribute("uri");
$generatorVersion = $xpath->query("//channel/generator")->item(0)->getAttribute("version");
$generator = $generatorNode->nodeValue;
$generatorUri = $generatorNode->getAttribute("uri");
$generatorVersion = $generatorNode->getAttribute("version");
//printf("<p>Generator: %s</p>", $generator);
//printf("<p>Generator URI: %s</p>", $generatorUri);
//printf("<p>Generator version: %s</p>", $generatorVersion);
Expand Down
28 changes: 14 additions & 14 deletions sampleFeed.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>RSS Title</title>
<description>This is an example of an RSS feed</description>
<link>http://www.example.com/main.html</link>
<lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
<ttl>1800</ttl>
<generator>newtelligence dasBlog 4.0.0.0</generator>

<item>
<title>Example entry</title>
<description>Here is some text containing an interesting description.</description>
<link>http://www.example.com/blog/post/1</link>
<guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>
<title>RSS Title</title>
<description>This is an example of an RSS feed</description>
<link>http://www.example.com/main.html</link>
<lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
</item>
<ttl>1800</ttl>
<generator>newtelligence dasBlog 4.0.0.0</generator>

<item>
<title>Example entry</title>
<description>Here is some text containing an interesting description.</description>
<link>http://www.example.com/blog/post/1</link>
<guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
</item>

</channel>
</rss>

0 comments on commit d9b504d

Please sign in to comment.