-2

How to read RSS Feed by using Java Script.

As I am Android developer I am very new In Java Script I have basic knowledge That's why I have not tried any thing.

I just want to know is this possible to do by javascript if yes then any one please give me the basic idea so that I will start.

Below is my code that I have tried. But it is not working.

function latestQuaterly()
{
 alert("Onclick Event is occur");
 com.myjavatools.xml.Rss rss = new com.myjavatools.xml.Rss(new java.net.URL("http://219.64.5.9/androidwebservice/RssFeed.aspx?linkname=annualreport";)); 
 int increment = 0; 
 for (java.util.Iterator i = rss.getItems().iterator(); i.hasNext();)
  { 
    if (increment > 1) { 
        break; 
        } 
        increment++; 
        com.myjavatools.xml.Rss.Item item = (com.myjavatools.xml.Rss.Item) i.next();
   }
   alert("count is :"+increment);
 }

In side the the RSS feed their is Title, Description and link I want to retrieve that separately .

mayur rahatekar
  • 4,410
  • 12
  • 37
  • 51
  • http://stackoverflow.com/questions/6929510/problem-parsing-rss-feed-using-javascript – Samir Mangroliya Feb 21 '12 at 11:07
  • 1
    The very first step should always be Googling. Questions like this *always* have thousands of good resources available for those who search. E.g. `javascript parse RSS` seems to yield good results. If you run into problems working with *those*, *that* will then be a good Stack Overflow question – Pekka Feb 21 '12 at 11:09
  • @Pekka Thanks a lot for your Information.... I don't know that..... – mayur rahatekar Feb 21 '12 at 11:14
  • 1
    That code looks like it starts out as JavaScript then tries to be Java, then goes back to JavaScript. You can't switch languages like that. – Quentin Feb 21 '12 at 11:58

1 Answers1

1

if you want to do it in jsp file, you can write java code inside scriptlet tag and use the java rss library ----http://www.myjavatools.com/projects/v.1.4.2/xml/doc/com/myjavatools/xml/Rss.html

The library provide methods to read all feeds from the given url and supported methods to display each feed seperately.

mini
  • 545
  • 3
  • 8
  • @ChrisW Thanks a lot for your information. do you have any solution for Javascript. on the above question that I have asked. or you have just read the Tags. – mayur rahatekar Feb 21 '12 at 11:20
  • 1
    here is the scriptlet code we are using in our application <% com.myjavatools.xml.Rss rss = new com.myjavatools.xml.Rss(new java.net.URL("http://xxx.com/feed/")); int increment = 0; for (java.util.Iterator i = rss.getItems().iterator(); i.hasNext();) { if (increment > 1) { break; } increment++; com.myjavatools.xml.Rss.Item item = (com.myjavatools.xml.Rss.Item) i.next(); %> – mini Feb 21 '12 at 11:25
  • given url is dummy one. pls use ur feed url there – mini Feb 21 '12 at 11:27
  • @mini I am developing the android application. In that HTML5 and Java script will give the support. So by using above java script code can we read the Rss Feed. – mayur rahatekar Feb 21 '12 at 11:31
  • sorry i am not aware of android but we used it in java application. u may find the way here--http://stackoverflow.com/questions/226663/parse-rss-with-jquery – mini Feb 21 '12 at 11:37