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 : 15073
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>



Simple newsreader script
Categories : PHP, XML, Rich Site Summary (RSS)
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)
Glossword - glossary compiler
Categories : Content Management, PHP, MySQL, XML
AutoRSS
Categories : PHP, Rich Site Summary (RSS), PHP Classes
MySQL or SQL Query to XML Output
Categories : PHP, MySQL, XML, Databases
MySQL to XML.
Categories : MySQL, XML, PHP
Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects.
Categories : PHP, PHP Classes, XML, Web Services
XML To Array
Categories : PHP, PHP Classes, 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
On-the-fly drop down menu from a txt or xml file
Categories : PHP, XML, HTML and PHP
Football News Aggregator
Categories : PHP, Object Oriented, PHP Classes, Rich Site Summary (RSS), HTML and PHP
XML easy parser
Categories : PHP, XML
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
Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript.
Categories : PHP, Java Script, DOM XML, XML, Arrays
 Niels Oesten wrote :1070
The function to translate udf-8 of course should be the standard utf8_decode().