How to use PHP to insert RDF in the Web site (1)

zhaozj2021-02-16  51

Honorary and huge wealth

Imagine a site from the most popular portal to get the latest news. Stock price, weather information, news stories, line discussion group, software release ... All this will be dynamically updated, once every hour, no manual intervention. We can imagine that the amount of site visits, the continuous advertising revenue, and the "Akala" of the Net Management Adults.

But now, stop fantasy, start reading, because as long as you pay close attention to this technology, maybe you can become the owner of the site. For your request is just a slight imagination, some smart PHP encodings and several free RSS files. In addition, it is clear that nine parts remaining in this article.

With content, Joint CONTENT, WILL SYNDICATE

We started from the most basic beginning - What is the RSS?

RSS (ie RDF Site Summary) is a format, which is the first description of the contents of the contents on my portions my.netscape.com. Since 1997, a few will be able to click on the link at the end of the article to learn about the long history of RSS. The current stable version is RSS1.0, which is in line with the RDF specification. This version can be said to be light and fun.

The RSS makes it possible to make the network management to promptly publish and distribute the description of the description of the latest most interesting content of a particular location of a particular site. From news articles list to stock market data or weather forecasts, all of which can be released through a good XML document, and can also be analyzed, processed and translated by any XML analyzer.

The list of the latest information on the website is frequently updated, and the RSS makes the distribution of this list possible, which also opened the door for the simple content Simple content on the Web. For the truth, please see the simple example below:

Site A, a news site ("Content Cindida Organizer"), can publish an RSS document containing the latest news list and the corresponding link per hour. This RSS document can be obtained by other sites (such as site B, "Content Collectors"), analyzing and displayed on the index page of site B. Each time a new RSS document is issued, the index page of the site B can be updated automatically to get the latest news.

This solution is effective for both parties in the transaction. Since the links in the RSS document point to the appropriate article on site A, the site A will quickly experience the increase in access. The network management of the site B can take a break a week, because he has a way to automatically update the index page on its site, and this method is merely connecting the index page with the dynamic content released by the site A.

There are many popular sites with detailed RSS or RDF news to the public, such as Freshmeat (http://www.freshmeat.net) and SlashDot (http://www.slashdot.org), of course there are many other sites. In this article, I will widely use the RDF file of the Freshmeat website. One point to explain is that the techniques discussed here can also be applied to any other RSS1.0 or RDF file.

Switching channel (Switching Channels)

A typical RSS document contains a list of resources marked by descriptive metadata, please see the example below:

Trog </ Title></p> <p><Description> Well-Written Technical Articles and</p> <p>Tutorials On Web Technologies </ Description></p> <p><link> http://www.melonfire.com/community/columns/trog/ </ link></p> <p><items></p> <p><RDF: SEQ></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 100 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 71 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 62 "/></p> <p></ rdf: SEQ></p> <p></ items></p> <p></ CHANNEL></p> <p><Item</p> <p>RDF: About = "http://www.melonfire.com/community/columns/trog/Article.php?i</p> <p>D = 10</p> <p>0 "></p> <p><title> building a php-based mail client (part 1) </ title></p> <p><link> http://www.melonfire.com/Community/Columns/trog/Article.php?id=100</p> <p></ li</p> <p>NK></p> <p><Description> EVER WONDERED How Web-Based Mail Clients</p> <p>Work? Find Out here. </ description></p> <p></ item></p> <p><Item</p> <p>RDF: About = "http://www.melonfire.com/community/columns/trog/Article.php?i</p> <p>D = 71 "></p> <p><title> Using PHP with XML (Part 1) </ Title></p> <p><link> http://www.melonfire.com/community/columns/trog/Article.php?id=71 <</p> <p>/ LINK></p> <p><Description> Use PHP's SAX Parser to Parse XML Data and</p> <p>Generate HTML Pages. </ description></p> <p></ item></p> <p><Item</p> <p>RDF: About = "http://www.melonfire.com/community/columns/trog/Article.php?i</p> <p>D = 62 "></p> <p><title> Access granted </ title> <link> http://www.melonfire.com/community/columns/trog/Article.php?id=62 <</p> <p>/ LINK></p> <p><Description> Precisely Control Access To Information</p> <p>With the mysql grant tables. </ description></p> <p></ item></p> <p>You can see that the RDF file consists of several boundary points. The first is the document code (proLog).</p> <p><? XML Version = "1.0" encoding = "UTF-8"?></p> <p>Then the namespace declaration in the root element.</p> <p><RDF: RDF XMLns: RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"</p> <p>XMLns = "http://purl.org/rss/1.0/"> Next, it is the <channel> section, which includes general information of the channel to which RDF to be described. In the above example, the channel is the Trog column of the Melonfire website, and the column content is a new technical article and guide, updated every week.</p> <p><channel rdf: About = "http://www.melonfire.com/"></p> <p><title> Trog </ Title></p> <p><Description> Well-Written Technical Articles and</p> <p>Tutorials On Web Technologies </ Description></p> <p><link> http://www.melonfire.com/community/columns/trog/ </ link></p> <p><items></p> <p><RDF: SEQ></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 100 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 71 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 62 "/></p> <p></ rdf: SEQ></p> <p></ items></p> <p></ CHANNEL></p> <p>The <channel> zone contains a <items> block, the <items> block further contains a sequential list of all resources described in the document. This list is represented by a series of <li /> elements. Each of the blocks in the block has a more detailed description in the <Item> block.</p> <p><items></p> <p><RDF: SEQ></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 100 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/column/trog/Article.php?id</p> <p>= 71 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 62 "/></p> <p></ rdf: SEQ></p> <p></ items></p> <p>You can also place a <image> block, so you can post the URL of the channel logo.</p> <p>So for meat, each <item> block in the RSS1.0 document describes a separate resource, including headings, URLs, and resource descriptions.</p> <p><items></p> <p><RDF: SEQ></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 100 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 71 "/></p> <p><li</p> <p>RDF: resource = "http://www.melonfire.com/community/columns/trog/Article.ph</p> <p>p? id</p> <p>= 62 "/></p> <p></ rdf: SEQ></p> <p></ items></p> <p>In this example, the <Item> block describes a separate article in the TTROG "Channel" and provides description and title for this article, and URL. Content collectors can create a "back" link using the URL.</p> <p>You can see that the RSS1.0 file is quite straightforward, whether it is manual, or by programming, it is very easy to create. The above examples and explanations are merely illustrative, usually, you can do more things with RSS1.0 and RDF. You'd better look at the links provided at the end of the article to get more information. But before this, let's take a few minutes to discuss all the RSS1.0 documents into your own Web site.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-27961.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="27961" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'RnYxc9x1ACYSntETt209C1V7YsiNbxFyBZFJEy7mKwqQyN_2B8TDq1HTy8FQFrNsKoOagFM9sArOEKR5Sv3fYkCw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>