Imagine a site that gets the latest news from the hottest portal site. Stock prices, weather information, news stories, thread discussion groups, software releases ... All of this will be dynamically updated once per hour without any manual intervention. We can imagine this attendant site traffic, a steady stream of advertising revenue and the "flattery" of the adult administrator.
But now, stop fantasizing and start reading, because as long as you keep an eye on the technology, you might be the owner of the site. Your request is just a little imagination, some smart PHP coding and a few free RSS files. In addition, it is clear that the remaining nine parts of this article are included.
With content, it is syndicated (Have content, will syndicate)
Let's start with the basics-what the heck is RSS?
RSS (that is, RDF Site Summary) is a format that was first designed by Netscape to distribute descriptive information about the content on My.Netscape.Com of its portal site. Since 1997 has been proposed, after several ups and downs-you can click on the link at the end of the article to understand the history of RSS long and complex. The current stable version is RSS1.0, which conforms to the RDF specification. This version can be said to be lightweight and full-featured.
RSS makes it possible for network administrators to publish and distribute the descriptive information of the latest and most interesting content in a particular location in a particular site in a timely manner. From a news article list to a stock market or a weather report, all of this information can be published through well-formed XML documents, which can also be analyzed, processed, and translated by any XML parser.
The list of the latest information on the site is frequently updated, and RSS makes the distribution of this list possible and opens the door for a simple syndicated syndication of content on the Web. To understand the truth of this, consider the following simple example:
Site A, a news site ("Content Syndicate organizer"), is able to publish an hourly RSS document containing the latest news listings and corresponding links. This RSS document can be retrieved by other sites (such as Site B, "content collectors") and is analyzed and displayed on the index page of site B. Each time site A publishes a new RSS document, Site B's index pages are automatically updated to get the latest news.
This scheme is effective for both parties in the transaction. Since the links in the RSS document point to the corresponding article on site A, then site A will quickly experience an increase in the number of visits. Site B's network management can take one weeks off because he has the means to automatically update the index page on his site, which simply connects the index page to the dynamic content published by site A.
There are many popular sites that provide detailed RSS or RDF news to the public, such as Freshmeat (Http://www.freshmeat.net) and Slashdot (http://www.slashdot.org) and, of course, many other sites. In this article, I will extensively use the RDF files of the Freshmeat Web site. The point to note is that the techniques discussed here can also be applied to any other RSS1.0 or RDF file.
Switching channels (switching channels)
A typical RSS document contains a list of resources (URLS) that are flagged by descriptive metadata, see the following example:
<channel rdf:about= "http://www.melonfire.com/" >
<title>Trog</title>
<description>well-written Technical Articles and
Tutorials on Web technologies</description>
<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>
<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>
As you can see, the RDF file consists of several well-defined parts. The first is the document sequence code (prolog),
<?xml version= "1.0" encoding= "UTF-8"?>
Then the namespace declaration 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/" >
Then there is the <channel> section, which contains general information about the channel to be described by RDF. In the example above, the channel is the Trog column of the Melonfire Web site, which is a new technical article and guide, updated every week.
<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> area contains a sequence list of <items> block,<items> blocks and all the resources described in the document. The list is represented by a series of <li/> elements. Each resource in the block is described in more detail in the <item> block that follows.
<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>
You can also place a <image> block in it so you can publish the URL of the channel flag.
So for meat, each <item> block in the RSS1.0 document describes a separate resource in more detail, including headings, URLs, and resource descriptions.
<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>
In this example, the,<item> block describes a separate article in the Ttrog "channel" and provides a description and caption, as well as a URL for this article. Content collectors can use URLs to create "backwards" links.
As you can see, the RSS1.0 file is quite intuitive and easy to create, either manually or programmatically. The above examples and explanations are only illustrative, and usually you can do more with RSS1.0 and RDF. You'd better look at the links provided at the end of the article to get more information. Before we do that, however, we'll spend a few more minutes discussing how to insert a RSS1.0 document into your own web site.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.