Newsletter
numPosts = 5; $config->targetFeed = "https://bestdentistnews.com/?feed=rss2"; $config->showTitle = true; $config->showLink = false; $config->showDate = true; $config->showContent = true; /* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx */ $newDoc = new DOMDocument(); $newDoc->load($config->targetFeed); $config->tags = $newDoc->getElementsByTagName("*"); foreach($config->tags as $thisTag) { if($thisTag->nodeName == "feed") { parseAtom($newDoc,$config); break; } elseif($thisTag->nodeName == "rss") { parseRSS($newDoc,$config); break; } } function parseRSS($doc,$settings) { $counter = 0; $fullList = $doc->getElementsByTagName("item"); foreach($fullList as $thisItem) { if ($counter >= $settings->numPosts) { break; } $values = $thisItem->getElementsByTagName("*"); $title = ""; $link = ""; $date = ""; $content = ""; foreach($values as $node) { if($node->nodeName == "title" && $settings->showTitle == true) {$title = $node->nodeValue;} if($node->nodeName == "link" && $settings->showLink == true) {$link = $node->nodeValue;} if($node->nodeName == "pubDate" && $settings->showDate == true) {$date = $node->nodeValue;} if($node->nodeName == "content:encoded" && $settings->showContent == true) {$content = $node->nodeValue;} } outputHTML($title,$link,$date,$content); $counter++; } } function parseAtom($doc,$settings) { $counter = 0; $fullList = $doc->getElementsByTagName("entry"); foreach($fullList as $thisItem) { if ($counter >= $settings->numPosts) { break; } $values = $thisItem->getElementsByTagName("*"); $title = ""; $link = ""; $date = ""; $content = ""; foreach($values as $node) { if($node->nodeName == "title" && $settings->showTitle == true) {$title = $node->nodeValue;} if($node->nodeName == "link" && $settings->showLink == true && $node->attributes->getNamedItem("rel")->nodeValue == "alternate") {$link = $node->attributes->getNamedItem("href")->nodeValue;} if($node->nodeName == "published" && $settings->showDate == true) {$date = $node->nodeValue;} if($node->nodeName == "content" && $settings->showContent == true) {$content = $node->nodeValue;} } outputHTML($title,$link,$date,$content); $counter++; } } function outputHTML($t,$l,$d,$c) { if ($t != "") { echo ""; if ($l != "") { echo ""; } echo $t; if ($l != "") { echo ""; } echo "
"; } if ($d != "") { echo "" . date('F jS Y',strtotime($d)) . "
"; } if ($c != "") { echo "" . $c . "
"; } } ?>