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 : 15636
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)
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
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
utf8_decode -- Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1.
Categories : PHP, PHP Functions, XML
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
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)
Amazon.com API, CURL-REST Parser. Obtain data about Amazon products (PHP5 +)
Categories : PHP, Ecommerce, XML, Web Services, CURL
AutoRSS
Categories : PHP, Rich Site Summary (RSS), PHP Classes
Trivia Quiz program using XML, XSLT and PHP
Categories : PHP, XML, XSLT
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
logger class (PHP5 +)
Categories : PHP, PHP Classes, Log Files, XML
MySQL or SQL Query to XML Output
Categories : PHP, MySQL, XML, Databases
XMLManipulation
Categories : PHP, XML, SimpleXML
Glossword - glossary compiler
Categories : Content Management, PHP, MySQL, XML
 Niels Oesten wrote :1070
The function to translate udf-8 of course should be the standard utf8_decode().