.One feed processor from a large Content Management System written in PHP nearly got me kicked off my server. It ran wild with overly complex coding and included opening hundreds of objects in a loop and used the XML-DOM (ugh!).I used the PHP DOM XML functions to do the processing. It this a bad idea? I could possibly see it is a necessary if you do have a non-RSS feed, or a complex XSL file to transform it, but perhaps for a simple RSS feed transform it is overkill. Should I perhaps put in the instructions for the xslt snippet that they should in fact use this one for simple display of RSS feeds?
if ( $url == "" ) return false;
if ( $limit == "" ) $limit = "0";
if ( $image == "" ) { $bimage = false; } else { $bimage = true; }
if ( $descr == "" ) { $bdescr = false; } else { $bdescr = true; }
The webpage is unpublished? might that affect something?
I just tested the feed URL on a local test installation with NewsParserX and it immediately displayed the feed, with no problems. Did you copy and paste the snippet into a new snippet for NewsParserX as well? Can you paste the exact template tag or API call you are using to call NewsParserX?
<?php
?>
[[NewsParserX? &url=`http://www.mil.se/rss/forsvarsmakten/index.html`]]
NewsParserX
# NewsParserX - for MODx 0.9.x # Version 0.9 - 2006-04-02 # By: OpenGeek - [email protected] # RSS parser shamelessly adapted from the RSS_feed class # see http://www.phpclasses.org/browse/package/1299.html # # This parser allows for more sorts of feeds # and by using a simple URL translation allows for parsing of URLs # which use variables within the URL # The class can also limit the number of items shown and show the image # For interoperatebility, the same CSS classes are used # as in rad's NewsParser snippet ;-) # # usage: # [[NewsParserX? &url=`http://modxcms.com/forums/index.php|xq|sa|xe|recent;type|xe|rss2;action|xe|.xml|xa|limit|xe|20`]] # or: # $modx->runSnippet('NewsParserX', array('url'=> 'http://modxcms.com/forums/index.php?sa=recent;type=rss2;action=.xml&limit=20')); # # Changes: # 1. 2006-04-02: Removed htmlentities() call to allow complex URLs to operate properly. # # original credits and comments kept: /******************************************************************** Class: RSS_feed Author: Dr. Timothy Sakach Version 2.0 This script will parse a RSS/XML file that comes from a URL feed. It will return an HTML unordered list. Getting a feed from another web site, should be quick and simple. Any unneeded complications should be avoided. One feed processor from a large Content Management System written in PHP nearly got me kicked off my server. It ran wild with overly complex coding and included opening hundreds of objects in a loop and used the XML-DOM (ugh!). This is far simpler, faster and more reliable. There are several versions of RSS/RDF. However, in practical use most all feed implementations follow the same pattern: A publication link is contained within <item> tags and consists of a <title>, <link>, and a <description>. We tested feeds from many different sources using all flavors and versions and this class was able to parse all of them. Granted there are many options with version 1.0 (RDF). However, the full RDF syntax and vocabulary are not needed in a feed. All of the implementations we found that included RDF tags really added very little to the feed and were safely ignored. Version 2.0 extends versions 0.9x by adding new tags. This presented no problems and this class can be extended to process those tags. But our goal was to provide a simple solution that can easily add syndicated publications to any web site. Changes: by Dr. Timothy Sakach 1. 8/31/03 Corrected bug because the description tag (and all other tags, for that matter} can occur in any sequence within the container tags. 2. 8/31/03 Corrected bug created by the way the XML parser returns parsed cdata. 3. 8/31/03 Added Set_Limit property to control the number of links to show. 4. 8/31/03 Added image control and Show_Image property. 5. 8/31/03 Channel, Image, and Items now use arrays as buffers. ********************************************************************/ $output = ''; // defaults and variable translation $url = str_replace ( "|xq|", "?", $url ); $url = str_replace ( "|xe|", "=", $url ); $url = str_replace ( "|xa|", "&", $url ); //$url = htmlentities($url); $url = html_entity_decode($url); if ( $url == "" ) return false; if ( $limit == "" ) $limit = "0"; if ( $image == "" ) { $bimage = false; } else { $bimage = true; } if ( $descr == "" ) { $bdescr = false; } else { $bdescr = true; } // end of defaults and variable translation // load class if it doesn't already exist // to handle multiple instances per page if (!class_exists("RSS_feed")) { include "assets/snippets/newsparserx/newsparserx.inc.php"; } $px = new RSS_feed(); $px->Set_URL($url); $px->Set_Limit($limit); // 0 = Default = All $px->Show_Image($bimage); // Default = false $px->Show_Description($bdescr); // Default = false // $output .= "<br />" . $url . "<br />"; // for debugging $output .= $px->Get_Results(); return $output;