Sometimes, your blog may need such a feature:
In their blog on the aggregation and display of Friends blog The latest article, so convenient for their timely understanding of friends, in addition, also facilitate visitors to find and this blog related blogs and articles.
This function you can call it "blog aggregation" or "blog network", at present, to achieve such a function of the software or services are limited: for example, Terac Sinfonia, Lilina, Mxna Although the function is very powerful, but need to install, can not be freely customized, Cannot embed in the blog sidebar. On the other hand, the BSP currently providing such services can only aggregate users within the system, with a lot of restrictions.
To solve the above problem, I used Ajax (asynchronous JavaScript + XML) technology to achieve a blog on their own to aggregate and display a friend blog The latest article features, you can, as required, free customization. The default is to support the RSS 2.0 specification, Terac Miracle, movable Type, Word Press, donews/Blog Park/csdn. Text system can be very good support, you can modify, to support RSS 0.92, RSS 1.0, Atom 0.3.
Why use Ajax? First of all, the aggregation of other people's RSS can not affect the speed of their own site, so need asynchronous execution, second, RSS itself is a very normative XML document, in addition, because the aggregation content size is not set, so must be local refresh, the most important point, Using AJAX to completely load parse XML operations to the client to process, save server bandwidth and resources, and finally, this feature I completely with JavaScript implementation, so that no matter your blog is ASP,. Net, PHP, JSP, Perl, and even pure HTML can be used. Here is the usage:
First, add a piece of code to the appropriate location in your blog sidebar:
<script src= "Ajax_rss.js" type= "Text/javascript" ></script>
Then save the following to "Ajax_rss.js" and upload it to the appropriate location on the server:
You are free to add RSS that conforms to the RSS 2.0 specification
Processrss (' http://www.songlian.cn/blog/feed.php ');
Processrss (' http://www.bo-blog.com/weblog/feed.php ');
function Processrss (URL) {
var req = Getxmlhttprequest ();
Req.onreadystatechange = function () {
if (req.readystate = = 4 && req.status = 200) {
var doc=req.responsexml.documentelement;
parseRSS (DOC);
}
}
Req.open ("Get", url, True);
Req.send (NULL);
}
function parseRSS (DOC) {
If you want to use RSS 0.92, RSS 1.0, Atom 0.3, you need to change the following 3 lines
var blogname=doc.getelementsbytagname ("title") [0].firstchild.data;
var entryname=doc.getelementsbytagname ("title") [1].firstchild.data;
var entrylink=doc.getelementsbytagname ("link") [1].firstchild.data;
document.getElementById (' Ajax_rss '). InnerHTML + = ' <a target= ' _blank ' href= ' ' +entrylink+ ' ' title= ' ' +blogname+ ' ' > ' +entryname+ ' </a><br/> '; }
function Getxmlhttprequest () {
var xmlhttp;
try {
XMLHTTP = new ActiveXObject ("Msxml2.xmlhttp");
catch (e) {
try {
XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");
catch (e) {
XMLHTTP = false;
}
}
if (!xmlhttp && typeof xmlhttprequest!= ' undefined ') {
XMLHTTP = new XMLHttpRequest ();
}
return XMLHTTP;
}
OK, the installation is over, test it!