Free lunch (a free lunch)
The class I wrote above is also very basic, which is to explain the problem, and may also be used for low-visitive sites. If you want to find some more professional things, go online, there are many Open source RDF analyzers, they have a variety of additional features (including cache). Then let us see how to use these analyzers.
The first thing to talk about is the RDF analyzer class developed by Stefan Saasen to the FASE4 website, you can download from http://www.fase4.com/rdf/. This is a very fully equipped RDF analyzer, supports cache and certification by proxy. Here's how to use it:
Body {font-family: verdana; font-size: 11px;}
.fase4_rdf {font-size: 13px; font-family: verdana} .fase4_rdf_title
{font-size: 13px; font-weight: bolder;}
style>
hEAD>
// incrude class
INCLUDE ("rdf.class.php");
// instantiate object
$ rdf = new fase4_rdf;
// set number of items to display
$ rdf-> set_max_item (5);
// set rdf engine options
$ RDF-> Use_Dynamic_display (true);
$ rdf-> set_options ("image" => "hidden", "textInput" => "hidden"));
// Parse and Display Data
$ RDF-> PARSE_RDF ("http://www.freshmeat.net/backend/fm-releases.rdf");
$ RDF-> Finish ();
?>
body>
html>
Another PHP RDF analyzer developed by Jason Williams can be downloaded at http://www.nerdzine.net/php_rdf/. This is a basic approach that does not have any any rendering of PHP classes. But it contains a lot of properties that allow you to arrange the processed data until you are satisfied.
hEAD>
INCLUDE ("RDF_CLASS.PHP");
// this Needs to be a local file
$ f = new rdffile ("./ fm-transases.rdf");
$ F-> Parse (TRUE);
$ F-> Returntable (True, "Black", "White", "100%");
?>
body>
html>
Documents on these classes have a presentation on their respective websites. Add a little style (Add a Little Style)
In case you hate to traverse those PHP arrays and mark them in HTML, then you can also choose to format and display this data by using the XSLT style. PHP4 .1 can support the Sablotron XSLT processor through the new XSLT API, the new API can be used to merge a XSLT style single and an XML document (here, the RDF file), which is very easy to convert the XML mark to browse Readable HTML tag.
I don't want to talk about it here, you can look at the PHP manual, or pay attention to the link behind this article to get more detailed information. However, I will still give a simple example to illustrate this problem. First, give the pattern single file:
XML Version = "1.0"?>
XMLns: rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" XMLns: rss = "http://purl.org/rss/1.0/" XMLns: DC = "http://purl.org/dc/elements/1.1/" Version = "1.0"> "- main page ->
hEAD>
ul>
body>
html>
xsl: template>
/> xsl: attribute> b> xsl: template>
/> xsl: attribute> xsl: template> xsl: stylesheet> Below is a PHP script, used to merge the above style list and "fresh meat" RDF document, generate an HTML page: PHP // xml file // this Needs to be a local file $ xml = "fm-releases.rdf"; // xslt file $ xslt = "fm.xsl"; // Create a new xslt processor $ xp = xslt_create (); // Transform the xml file as per the xlt stylesheet // Return The Result to $ RESULT $ Result = XSLT_Process ($ XP, $ XML, $ XSLT); IF ($ Result) { // Print IT Echo $ Result; } // Clean Up XSLT_Free ($ XP); ?> I think this is quite simple, there is no need to add anything. The two documents combined together, producing the following "synthetic": This is another way to convert RDF data into browser readable HTML, perhaps simple (although not ideal). But pay attention, you need to run an external program to regularly update your local copy of your RDF file because the PHP XSLT processor may have difficulty accessing the remote file. Homework (HOMEWORK) If you are interested in talking to the technical understanding of these texts, you can consider accessing the link below: RSS 1.0 specification: Http://www.purl.org/rss/1.0/rss development history: Http://backend.userland.com/stories/rss091w3c About RDF content: Http://www.w3.org/rdf/php discussion about SAX and DOM programming: http://www.devshed.com/server_side/xml/xmlwithPHP Realize the discussion of XSLT conversion with PHP: Http://www.devshed.com/server_side/xml/xsltrans About PHP Class Discussion: Http://www.devshed.com/server_side/php/backtoclassxml foundation discussion: Http://www.devshed.com/server_side/xml/xmlbasic xslt foundation discussion: Http://www.devshed.com/server_side/xml/xslbasics php manual About SAX function content: Http://www.php.net/manual/en/ref.xml.PHP PHP Manual About the XSLT function: http://www.php.net/manual/en/ref.xslt.php Next time you see ... take care of your body! Note: All examples in this article are tested in Linux / I386, Apache 1.3.12, PHP4.1.1.