469,917 Members | 1,473 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

How to retrieve RSS feed from blogger?

Here's the code for the index.xml file on the blogger

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version="1.0" encoding="<$MTPublishCharset$>"?>
  3. <rss version="2.0">
  4.    <channel>
  5.       <title><$MTBlogName remove_html="1" encode_xml="1"$></title>
  6.       <link><$MTBlogURL$></link>
  7.       <description><$MTBlogDescription remove_html="1" encode_xml="1"$></description>
  8.       <language><$MTBlogLanguage ietf="1"$></language>
  9.       <copyright>Copyright <$MTDate format="%Y"$></copyright>
  10.       <lastBuildDate><MTEntries lastn="1"><$MTEntryDate format_name="rfc822"$></MTEntries></lastBuildDate>
  11.       <generator>http://www.sixapart.com/movabletype/?v=<$MTVersion$></generator>
  12.       <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
  13.  
  14.       <MTEntries lastn="15">
  15.       <item>
  16.          <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
  17.          <description><$MTEntryBody encode_xml="1"$></description>
  18.          <link><$MTEntryPermalink encode_xml="1"$></link>
  19.          <guid><$MTEntryPermalink encode_xml="1"$></guid>
  20.          <category><$MTEntryCategory remove_html="1" encode_xml="1"$></category>
  21.          <pubDate><$MTEntryDate format_name="rfc822"$></pubDate>
  22.       </item>
  23.       </MTEntries>
  24.    </channel>
  25. </rss>
  26.  
Here's my javascript file which returns an allert that it could not handle the file -- I'm sure it has to do with me not defining what variables that the blogger is returning, but is there a way to handle such variables?

Expand|Select|Wrap|Line Numbers
  1.  
  2. var channelvar=xml_doc.getElementsByTagName('channel');
  3. var titlevar=xml_doc.getElementsByTagName('title');
  4. var linkvar=xml_doc.getElementsByTagName('link');
  5. var descriptionvar=xml_doc.getElementsByTagName('description');
  6. var languagevar=xml_doc.getElementsByTagName('language');
  7. var copyrightvar=xml_doc.getElementsByTagName('copyright');
  8. var lastBuildDatevar=xml_doc.getElementsByTagName('lastBuildDate');
  9. var generatorvar=xml_doc.getElementsByTagName('generator');
  10. var docsvar=xml_doc.getElementsByTagName('docs');
  11. var guidvar=xml_doc.getElementsByTagName('guid');
  12. var categoryvar=xml_doc.getElementsByTagName('category');
  13. var pubDatevar=xml_doc.getElementsByTagName('pubDate');
  14.  
  15.  
  16. for (i=0;i<channelvar.length;i++)
  17.   {
  18.   if (channelvar[i].nodeType==1)
  19.     { 
  20. document.writeln(titlevar[i].childNodes[0].nodeValue + '<br>');
  21. document.writeln("<a href='" + linkvar[i].childNodes[0].nodeValue + "' target=_blank>" + linkvar[i].childNodes[0].nodeValue + "</a><br>");
  22. document.writeln(descriptionvar[i].childNodes[0].nodeValue + '<br>');
  23. document.writeln(languagevar[i].childNodes[0].nodeValue);
  24. document.writeln(copyrightvar[i].childNodes[0].nodeValue);
  25. document.writeln(lastBuildDatevar[i].childNodes[0].nodeValue);
  26. document.writeln(generatorvar[i].childNodes[0].nodeValue);
  27. document.writeln(docsvar[i].childNodes[0].nodeValue);
  28. document.writeln(guidvar[i].childNodes[0].nodeValue);
  29. document.writeln(categoryvar[i].childNodes[0].nodeValue);
  30. document.writeln(pubDatevar[i].childNodes[0].nodeValue + "<br>&nbsp;<br>");
  31.     }
  32.   }
  33.  
  34.  
As usual, thanks in advance for any help :-)
May 20 '07 #1
1 1969
Dököll
2,364 Expert 2GB
Hi!

I am not sure why it is not doing what you intended it to. Here's an RSS Feed validator site: http://www.feedvalidator.org/

Give it a go, see what comes up, ok!
Jul 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.