PHP
  Home arrow PHP arrow Page 3 - Plugging RDF Content Into Your Web Site With PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Plugging RDF Content Into Your Web Site With PHP
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 19
    2002-02-27


    Table of Contents:
  • Plugging RDF Content Into Your Web Site With PHP
  • Have Content, Will Syndicate
  • Switching Channels
  • Fresh Meat
  • Capture The Flag
  • Nesting Time
  • Back To Class
  • Adding A Little Style
  • Homework

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Plugging RDF Content Into Your Web Site With PHP - Switching Channels
    ( Page 3 of 9 )

    An RSS document typically contains a list of resources (URLs), marked up with descriptive metadata. Here's an example:

    <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"> <channel rdf:about="http://www.melonfire.com/"> <title>Trog</title> <description>Well-written technical articles and tutorials on Web technologies</description> <link>http://www.melonfire.com/community/columns/trog/</link> <items> <rdf:Seq> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =100" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =71" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =62" /> </rdf:Seq> </items> </channel> <item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i d=10 0"> <title>Building A PHP-Based Mail Client (part 1)</title> <link>http://www.melonfire.com/community/columns/trog/article.php?id=100 </li nk> <description>Ever wondered how Web-based mail clients work? Find out here.</description> </item> <item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i d=71"> <title>Using PHP With XML (part 1)</title> <link>http://www.melonfire.com/community/columns/trog/article.php?id=71< /link> <description>Use PHP's SAX parser to parse XML data and generate HTML pages.</description> </item> <item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i d=62"> <title>Access Granted</title> <link>http://www.melonfire.com/community/columns/trog/article.php?id=62< /link> <description>Precisely control access to information with the mySQL grant tables.</description> </item> </rdf:RDF>
    As you can see, an RDF file is split up into very clearly-demarcated sections. First comes the document prolog,

    <?xml version="1.0" encoding="UTF-8"?>
    and namespace declarations in the root element.

    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
    This is followed by a <channel> block, which contains general information on the channel that is described by this RDF file. In the example above, the channel is Melonfire's Trog column, which gets updated every week with new technical articles and tutorials.

    <channel rdf:about="http://www.melonfire.com/"> <title>Trog</title> <description>Well-written technical articles and tutorials on Web technologies</description> <link>http://www.melonfire.com/community/columns/trog/</link> <items> <rdf:Seq> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =100" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =71" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =62" /> </rdf:Seq> </items> </channel>
    The <channel> block contains an <items> block, which contains a sequential list of all the resources described within the RDF document. This list is formulated as a series of <li /> elements, which may be familiar to you from HTML. Every resource in this block corresponds to a resource described in greater detail in a subsequent <item> block (further down).

    <items> <rdf:Seq> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =100" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =71" /> <li rdf:resource="http://www.melonfire.com/community/columns/trog/article.ph p?id =62" /> </rdf:Seq> </items>
    It's also possible to intersperse an <image> block at this stage, in case you'd like to publish the URL of your channel's logo.

    And now for the meat. Every <item> block in an RSS 1.0 document describes a single resource in greater detail, providing a title, a URL and a description of that resource.

    <item rdf:about="http://www.melonfire.com/community/columns/trog/article.php?i d=71"> <title>Using PHP With XML (part 1)</title> <link>http://www.melonfire.com/community/columns/trog/article.php?id=71< /link> <description>Use PHP's SAX parser to parse XML data and generate HTML pages.</description> </item>
    In this example, the <item> block above describes a single article in the Trog "channel", providing a description and title for it, and including a URL so that a content aggregator can create backward links to it.

    As you can see, an RSS 1.0 file is fairly straightforward, and it's quite easy to create one, either manually or programmatically. The example and explanation above was merely illustrative; there's a lot more you can do with RSS 1.0 and RDF in general, and you should take a look at the links provided at the end of this article for more information. Until we get there, though, let's spend a few more minutes discussing how an RSS 1.0 document like the one above can be plugged into your own Web site.

     
     
    >>> More PHP Articles          >>> More By icarus, (c) Melonfire
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT