PHP
  Home arrow PHP arrow Page 3 - Plugging RDF Content Into Your Web Sit...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway