WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : RSS parser using PHP5 and simpleXML
Categories : Rich Site Summary (RSS), PHP, XML Update Picture
Niels Oesten
Date : Apr 13th 2004
Grade : 2 of 5 (graded 2 times)
Viewed : 5839
File : 3820.zip
Images : No Images for this code example.
Search : More code by Niels Oesten
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

A very simple RSS parser using PHP 5.0.0RC1 and simpleXML.
This parser works fine on my local computer using Apache 1.3.29 (Windows)
and PHP 5.0.0RC1. It is adapted for my own layout using the stylesheet.


<HTML>
<HEAD>
<TITLE>RSS Feed fra Ingeniרren</TITLE>
<LINK REL=STYLESHEET HREF="../website.css">
</HEAD>
<BODY STYLE="margin-left:100px;margin-right:100px">
<?php
// Function translating Danish utf-8 (BOM) characters
function utfdan($instr)
   {
   
$trans = array("ֳ¦"=>"ז","ֳ¸"=>"ר","ֳ¥"=>"ו","ֳ†"=>"ֶ","ֳ˜"=>"״","ֳ…"=>"ֵ");
   
$encoded = strtr($instr, $trans);
   return
$encoded;
   }

// Number of items
$items = 15;

// Retrieve XML data
$simple = simplexml_load_file('http://rss.asdf.dk/ing.rss');

// Headline
$headline = utfdan($simple->channel->title);
echo
"<h1>$headline</h1>\n";

// Description
$description = utfdan($simple->channel->description);
echo
"<DIV CLASS=\"DIV18B\">$description</DIV><BR><BR>\n";

// Show the latest 15 items. The format is RSS 1.0
for($i=0;$i<$items;$i+=1)
   {
   
$title = utfdan($simple->item[$i]->title);
   
$desc = utfdan($simple->item[$i]->description);
   
$link = $simple->item[$i]->link; // Translation not necessary
   
echo "<DIV CLASS=\"DIV18B\"><a href=\"$link\" TARGET=\"_blank\">$title</a></DIV>\n";
   echo
"<DIV CLASS=\"DIV14N\">$desc</DIV><BR>\n";
   }
?>
</BODY>
</HTML>

Adaptation for version 0.91 is easy:

<HTML>
<HEAD>
<TITLE>RSS Feed from BBC</TITLE>
<LINK REL=STYLESHEET HREF="../website.css">
</HEAD>
<BODY STYLE="margin-left:100px;margin-right:100px">
<?
// number of items
$items = 15;

// Retrieve XML data
$simple = simplexml_load_file('http://www.bbc.co.uk/syndication/feeds/news/ukfs_news/world/rss091.xml');

// Headline
echo "<h1>{$simple->channel->title}</h1>\n";

// Time
echo "<DIV CLASS=\"DIV16B\">{$simple->channel->lastBuildDate}</DIV><BR><BR>\n";

// The latest items. The format is RSS 0.91
for($i=0;$i<$items;$i+=1)
   {
   echo
"<DIV CLASS=\"DIV18B\"><a href=\"{$simple->channel->item[$i]->link}\">{$simple->channel->item[$i]->title}</a></DIV>\n";
   echo
"<DIV CLASS=\"DIV14N\">{$simple->channel->item[$i]->description}</DIV><BR>\n";
   }
?>
</BODY>
</HTML>



RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
Simple newsreader script
Categories : PHP, XML, Rich Site Summary (RSS)
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
PHP Random rss feeds - selects 49 random feeds from an unlimited list and displays them on your website. It's Ideal for those moments when you got 5 minutes and dont know which one of your feeds to read.
Categories : PHP, Rich Site Summary (RSS), Arrays
XML To Array
Categories : PHP, PHP Classes, XML, Arrays
A very basic and fast XML parser
Categories : PHP, PHP Classes, XML
Glossword - glossary compiler
Categories : Content Management, PHP, MySQL, XML
XML easy parser
Categories : PHP, XML
Amazon.com API, CURL-REST Parser. Obtain data about Amazon products (PHP5 +)
Categories : PHP, Ecommerce, XML, Web Services, CURL
MySQL or SQL Query to XML Output
Categories : PHP, MySQL, XML, Databases
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
On-the-fly drop down menu from a txt or xml file
Categories : PHP, XML, HTML and PHP
Directory Listing To XML : Outputs XML File of a Given Directory Listing
Categories : PHP, PHP Classes, XML, Directories
Trivia Quiz program using XML, XSLT and PHP
Categories : PHP, XML, XSLT
 Niels Oesten wrote :1070
The function to translate udf-8 of course should be the standard utf8_decode().