alexdzyoba / feedparser Goto Github PK
View Code? Open in Web Editor NEWLibrary for parsing RSS/Atom feeds
Home Page: http://alex.dzyoba.com/FeedParser
License: GNU Lesser General Public License v3.0
Library for parsing RSS/Atom feeds
Home Page: http://alex.dzyoba.com/FeedParser
License: GNU Lesser General Public License v3.0
FeedParser ========== FeedParser is a PHP library that handles all types of XML feeds. Example ------- (Also, in feed.php) ```php <?php // The only thing we need is include base class file require_once('FeedParser.php'); // Get XML serialization of feed $xml = file_get_contents($_POST['filename']); // This is great. To work with feed we invoke only base class. All other work is // transparent. $feed = new FeedParser($xml); //Because we have interface for feeds, we invoke interface methods echo '<b>Type:</b>'.$feed->getFeedType()."<br/>"; echo '<b>Title:</b>'.$feed->getTitle()."<br/>"; echo '<b>Description:</b>'.$feed->getDescription()."<br/>"; echo '<b>Feed link:</b>'.$feed->getFeedLink()."<br/>"; echo '<b>Link:</b>'.$feed->getLink()."<br/>"; $items = $feed->getItems(); // Stuff in your items can be empty, so you should somehow handle it. // I've prepared is_empty function for you - enjoy. $i=1; foreach($items as $item) { //Because we have interface for items, we invoke interface methods echo "<h1>"; if(is_empty($item->getLink())) echo '<a href="#">'; else echo '<a href="'.$item->getLink().'">'; if(is_empty($item->getTitle())) echo "No title"; else echo "$i. ".$item->getTitle(); echo "</a>"; echo "</h1>"; if(is_empty($item->getPubDate())) echo "<i>"."No date"."</i><br/>"; else echo "<i>".$item->getPubDate()."</i><br/>"; if(is_empty($item->getContent())) echo "<i>"."No content"."</i><br/>"; else echo $item->getContent()."<hr/>"; $i++; } ?> ``` Features and API ---------------- It supports: * RSS 0.90 * RSS 1.0 * RSS 1.1 * RSS 0.91 * RSS 0.92 * RSS 2 * Atom 1 * Atom 0.3 (treated as Atom 1) It has 2 interfaces - one for work with feeds, and the other one is to work with feed's items. Methods: * Feeds - `getTitle()` - retrieve feed title - `getDescription()` - retrieve feed description - `getItems()` - retrieve feed items as array - `getLink()` - retrieve feed link (Link to feed website) - `getFeedLink()` - retrieve feed link to itself - `getFeedType()` - retrieve feed type as string * Items - `getTitle()` - retrieve item title - `getContent()` - retrieve item content as string - `getPubDate()` - retrieve item publication date as PHP date - `getLink()` - retrieve item link History ------- I read a lot. I have about 100 RSS/Atom subscriptions, that i read every day. It helps me to have actual knowledge and have fun. All feeds i read in google reader. However i didn’t like it much from the beginning because of small viewport. If you open google reader on small 1024×600 netbook screen you’ll understand what i’m talking about. For example, it’s really impossible to view photos. That’s why i’ve decided to write my own reader and get practice in PHP/Yii. So, if you want to read RSS/Atom, you have to parse it somehow. At first i wanted to use something already done and found XML_Feed_Parser library by James Stewart at PEAR. I’ve tried to fit it under my code, but despite all benefits, it wasn’t so “unified” as it was told in description. And that’s why I wrote my own library, based on James's work. Source code distributed under terms of LGPLv3. If you have any questions, suggestions or anything else – write me email to [email protected] or ask through github.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.