Aggregate RSS with Ajax technology


Sometimes, your blog may need such a function:
Gather and display the latest articles of friends’ blogs on your own blog, so that you can learn about your friends’ news in time. In addition, it is also convenient for visitors to find blogs and articles related to this blog.
You can call this function “blog aggregation” or “blog syndication”. At present, there are restrictions on the software or services to realize this function: for example, terac sinfonia, lilina and mxna, although all have powerful functions, need to be installed and cannot be customized freely or embedded into the blog sidebar. On the other hand, BSPs that currently provide such services can only aggregate users in the system, and there are many restrictions.
In order to solve the above problems, I used Ajax (asynchronous Javascript + XML) technology to realize the function of aggregating and displaying the latest articles of friends’ blogs on my blog. You can customize them freely according to your needs. RSS 2.0 specification is supported by default, and terac miracle, movable type, word press, DoNews / blog / CSDN are adopted The text system is well supported. You can modify it freely to support RSS 0.92, RSS 1.0 and atom 0.3.
Why Ajax? First of all, aggregating other people’s RSS can’t affect the speed of your own website, so it needs to be executed asynchronously. Second, RSS itself is a very standard XML document. In addition, because the size of the aggregated content can’t be determined, it must be refreshed locally. The most important thing is that AJAX is used to completely put the loading and parsing of XML on the client for processing, saving server bandwidth and resources. Finally, this function is completely implemented in JavaScript, In this way, no matter your blog is ASP Net, PHP, JSP, Perl, and even pure HTML can be used. Usage:
First, add such a code in the appropriate position of your blog sidebar:

Then save the following content as “ajax\u rss.js” and upload it to the corresponding location of the server:

Copy codeThe codes are as follows:
//You can freely add RSS that conforms to RSS 2.0 specification
  function processRSS(url){ 
    var req = getXMLHttpRequest(); 
    req.onreadystatechange = function () { 
      if (req.readyState == 4 && req.status == 200) { 
        var doc=req.responseXML.documentElement;  
    }“GET”,url, true); 
  function parseRSS(doc) { 
/ / if you want to use RSS 0.92, RSS 1.0, atom 0.3, you need to change the following three lines
    var blogName=doc.getElementsByTagName(“title”)[0]; 
    var entryName=doc.getElementsByTagName(“title”)[1]; 
    var entryLink=doc.getElementsByTagName(“link”)[1]; 
  document.getElementById(‘ajax_rss’).innerHTML += ”+entryName+’ 
‘; } 
  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. Let’s test it!