WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 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



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 : 3 of 5 (graded 4 times)
Viewed : 15732
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  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)
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
XML easy parser
Categories : PHP, XML, PHP Classes
XPath for PHP without the DOM XML extension
Categories : DOM XML, XML, XSLT, PHP Classes, PHP
php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage
Categories : PHP, AJAX, XML, Complete Programs
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
On-the-fly drop down menu from a txt or xml file
Categories : PHP, XML, HTML and PHP
A very basic and fast XML parser
Categories : PHP, PHP Classes, XML
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)
SAPIPROCESSOR - is a compact XML-based CMS toolkit
Categories : PHP, Content Management, XML
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
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
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
XML easy parser
Categories : PHP, XML
 Niels Oesten wrote :1070
The function to translate udf-8 of course should be the standard utf8_decode().