Hey Guys,

Go for this:

JavaScript:
=============================================================
/*Place this code externally*/
/* Function Used to Display Months in Words as Jan, Feb...*/
  function WordMonth(intMonth){
  var MonthArray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
  return MonthArray[intMonth]
}

/*Function Used to Fetch RSS Feeds from Other websites to yours...It
works with BoDY ONLOAD Functionality!*/
function GetRSSNews(){
  /*First*/

/*You can set as much as you want to display Feeds*/
 var iMax = 20

/*ActiveX Object Initialization*/
 var rssDoc = new ActiveXObject("Microsoft.XMLDOM")
 rssDoc.async = false


/*Insert your Required URL to be fetched>>For a test I have taken BBC
Feeds*/
 rssDoc.load("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/
front_page/rss.xml")

 /*You can assume it as DOM Structure of a XML Document for Logical
Means*/
 var headNode = rssDoc.selectNodes("/rss/channel")
 var itemNodes = rssDoc.selectNodes("/rss/channel/item")

 /*Condition to check if Length of item Nodes is greater or lesser
than the Parameter used to get no. of items displayed*/
 if(itemNodes.length<iMax){
  iMax = itemNodes.length
 }

 /*Variable Initialization for FEEDBODY*/
 var feedBody = ""

 /*For Loop Initialization to incoporate iMax Parameter for getting
Various items in display*/
 for(i=0;i<iMax;i++){


         var pubDate = new Date(itemNodes.item(i).getElementsByTagName
("pubDate").item(0).text)

         /*alert(pubDate+"-"+pubDate.getDate()+"/"+(pubDate.getMonth()
+1)+"/"+pubDate.getFullYear())*/

 var tempPubDate = pubDate.getDate()+ "&nbsp;" + WordMonth
(pubDate.getMonth())+ "&nbsp;" +pubDate.getFullYear()

feedBody = feedBody + tempPubDate + " <a style='text-transform:
lowercase;' class='article' target='_blank' href='" +

itemNodes.item (i).getElementsByTagName("link").item(0).text + "'>" +
itemNodes.item(i).getElementsByTagName("title").item

(0).text  +"</a><br /><br />"

}


myFeeds.innerHTML  = feedBody


}

=============================================================

HTML:
=============================================================
/*Place this code in the same folder assigning a name;eg:
index.html>>Also check for the paths I have used to call the
JavaScript, make sure that you modify as per your need!*/
<html>
<head>
<title>RSS Feeds Test</title>
</head>
<body class="mainBody" onload="GetRSSNews();">
<div id="myFeeds" style="padding: 0px 8px 0px 8px;"><script src="js/
rss/rss.js"></script></div>
</body>
=============================================================

I am sure this works out for you guys!.

Best Regards,
Ayusman Mohanty,
CSC
Reply me at: [email protected]




On Jan 25, 11:58 pm, Chister Nordvik <[email protected]> wrote:
> The issue has still "new" status so either Google is just ignoring it
> or they think it's a bug in my code.
>
> I tried a little more and I experienced similar problems when fetching
> XML that has encoded html inside the tags (typically RSS feeds). This
> code works perfectly when running on the desktop but on android it
> just refuses to give me the text after it encounters "&lt;" in this
> node:
> <description>Test html chars: &lt;b&gt;v2.1&lt;/b&gt; released.</
> description>
>
> The full sample code is included below in case someone would like to
> give it a try or tell me if I am missing something here!?
>
> Desktop output:
> ********* RSS: Test html chars: <b>v2.1</b> released. Read about the
> changes here!
>
> Android output:
> ****************Test html chars:
>
> Sample code:
>
>       URI rssurl = URI.create("http://www.hvaerstillingen.no/docs/rss/
> test.txt");
>       try {
>          DocumentBuilder builder =
>            DocumentBuilderFactory.newInstance().newDocumentBuilder();
>          Document doc = builder.parse(rssurl.toURL().openStream());
>
>          NodeList nodes = doc.getElementsByTagName("item");
>          for (int i = 0; i < nodes.getLength(); i++) {
>            Element element = (Element) nodes.item(i);
>
>            NodeList title = element.getElementsByTagName("title");
>            Element line = (Element) title.item(0);
>
>            Element descEl = (Element) element.getElementsByTagName
> ("description").item(0);
>            Node textNode = descEl.getFirstChild();
>            System.out.println("********* RSS: "+ textNode.getNodeValue
> ());
>          }
>        }
>        catch (Exception e) {
>           e.printStackTrace();
>        }
>
> -Christer
>
> On 1 Des 2008, 19:54, "Xavier Mathews" <[email protected]> wrote:> Ok 
> Great!
>
> > Xavier A. Mathews
> > Student/Browser Specialist/Developer/Web-Master
> > Google Group Client Based Tech Support Specialist
> > Hazel Crest Illinois
> > [email protected]¥[email protected]¥[email protected]
> > "Fear of a name, only increases fear of the thing itself."
>
> > On Mon, Dec 1, 2008 at 12:58 AM, ChisterNordvik <[email protected]> wrote:
>
> > > It's been added:
> > >http://code.google.com/p/android/issues/detail?id=1398
>
> > > -Christer
>
> > > On 1 Des, 01:55, "Xavier Mathews" <[email protected]> wrote:
> > > > Same Problem Here. Post It In The Issue Tracker!
>
> > > > On 11/30/2008, [email protected] <[email protected]>
> > > wrote:
>
> > > > > Yes, I have also encountered the same problem. Any suggestions?
>
> > > > > On Nov 30, 10:53 pm, ChisterNordvik <[email protected]> wrote:
> > > > >> Hi!
>
> > > > >> Does anyone have a workingRSSparser with Android? I tried doing
> > > > >> simple DOM parsing of the XML but the character encoding isn't 
> > > > >> handled
> > > > >> properly so the norwegian characters aren't displayed. I have tried
> > > > >> everything but when I get the description element I just get the text
> > > > >> until the norwegian character. Any sample code of parsing
> > > > >> internationalRSSfeeds would be very welcome!
>
> > > > >> Here is the feed that I am having problems
> > > > >> with:http://www.dagbladet.no/rss/fotball/
>
> > > > >> -Christer
>
> > > > >> Sample code that I started out with (have tried lots of encoding
> > > > >> tricks to no avail):
>
> > > > >> Feed feed = createFeed(this,
> > > > >>                                         new
> > > > >> java.net.URI("http://www.dagbladet.no/rss/fotball/";));
> > > > >> ...
> > > > >> public Feed createFeed(Context ctx, URI rssurl) {
> > > > >>                 Feed feed = new Feed();
> > > > >>                 try {
> > > > >>                      DocumentBuilder builder =
>
> > > > >>  DocumentBuilderFactory.newInstance().newDocumentBuilder();
> > > > >>                      Document doc =
> > > > >> builder.parse(rssurl.toURL().openStream());
>
> > > > >>                      NodeList nodes =
> > > doc.getElementsByTagName("item");
> > > > >>                      for (int i = 0; i < nodes.getLength(); i++) {
> > > > >>                        Element element = (Element) nodes.item(i);
>
> > > > >>                        NodeList title =
> > > > >> element.getElementsByTagName("title");
> > > > >>                        Element line = (Element) title.item(0);
>
> > > > >>                        String feedTitle =
> > > > >> getCharacterDataFromElement(line);
> > > > >>                        String url = getCharacterDataFromElement
> > > > >> (element.getElementsByTagName("link").item(0));
> > > > >>                        Article art = new Article();
> > > > >>                        art.title = feedTitle;
> > > > >>                        art.url = url;
> > > > >>                        art.description = getCharacterDataFromElement
> > > > >> (element.getElementsByTagName("description").item(0));
> > > > >>                        feed.articles.add(art);
>
> > > > >>                      }
> > > > >>                    }
> > > > >>                    catch (Exception e) {
> > > > >>                       e.printStackTrace();
> > > > >>                    }
> > > > >>                    return feed;
> > > > >>         }
> > > > >>         public static String getCharacterDataFromElement(Node e) {
> > > > >>                    Node child = e.getFirstChild();
> > > > >>                    if(child == null)
> > > > >>                            return "?";
> > > > >>                    if (child instanceof CharacterData) {
> > > > >>                      CharacterData cd = (CharacterData) child;
> > > > >>                        return cd.getData();
> > > > >>                      }
> > > > >>                    return "?";
> > > > >>                  }
>
> > > > --
> > > > Xavier A. Mathews
> > > > Student/Browser Specialist/Developer/Web-Master
> > > > Google Group Client Based Tech Support Specialist
> > > > Hazel Crest Illinois
> > > > [email protected]¥[email protected]¥[email protected]
> > > > "Fear of a name, only increases fear of the thing itself."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to