×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    21

    RSS feed in WRT Widget not working on device, but does in desktop browser

    Hi all.

    I've been trying to get an RSS feed to work in a wrt widget. When i test my code (running the .html file) in the Internet Explorer/Firefox desktop browser it works fine. However, if i install my widget on either my physical Nokia N95 8gb, or the device emulator provided with the Nokia SDK, i just get the response:

    "Error: Could not load RSS feed at this time.";

    So from this, i take it that req.status does not equal 200.

    Certainly my physical device has a SIM, and also network connectivity, so i have no idea why it doesn't work. I've enabled browser debugging, but no errors are displayed.

    Any advice, anyone? Thanks.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
     <title>test</title>
       
     <script type='text/JavaScript'>
    
    
      var req;
      var url;
      url = "http://www.mywebsite.co.uk/rss/mywebsiterss.xml";
      
      function loadRSSFeed() {
      if (null == req) {
    
       req = new XMLHttpRequest(); 
      }  	
      document.getElementById("content").innerHTML = "<br />&nbsp;&nbsp;Loading rss feed..."; 
      
      req.onreadystatechange = ReqStateChange;
     
      req.open("GET", url, true);
      req.send(null); 
     
      
    }
    function ReqStateChange() {
      if (req.readyState == 4) {
     
        if (req.status == 200) {
        	UpdateContent(req);
        } 
        else {
          /*
           * if widget is totally dependent of network connection you 
           * might consider notifying end user. error may occur due to 
           * network error (GSM/3G), no SIM inserted, invalid access point etc.
           * detailed information is not available.
           */
           document.getElementById("content").innerHTML = "Error: Could not load RSS feed at this time."; 
        }
      }
    }
    
    
    function UpdateContent(reqst) {
      var d = null;
      var el = document.getElementById("content");
      var tempcolor = "";
      var rss = null;
     
      var html = "";
      rss = reqst.responseXML.documentElement;
     
     
     
      if (rss != null) {
        var itemTitleNodes = rss.getElementsByTagName("title");
        var itemLinkNodes = rss.getElementsByTagName("link");
        var itemDescNodes = rss.getElementsByTagName("description");
        var itemPubNodes = rss.getElementsByTagName("pubDate");
        
        var c=itemTitleNodes.length;
     
        //el.innerHTML="Displaying " + c + " items...";
     
        if (c<=0) {
          return;
        };
     
       if (c>4) c=3; // limit to four stories
     
        for (var i = 0; i < c; i++) { 
        
          var itemLink, itemTitle, itemDesc;
     
          if ((itemTitleNodes[i].childNodes[0] != null) && (itemLinkNodes[i].childNodes[0] != null) && (itemDescNodes[i].childNodes[0] != null) && (itemPubNodes[i].childNodes[0] != null)) {
    
            itemTitle = itemTitleNodes[i].childNodes[0].nodeValue;
    		itemLink = itemLinkNodes[i].childNodes[0].nodeValue;
    		itemDesc = itemDescNodes[i].childNodes[0].nodeValue;
    		itemPubDate = itemPubNodes[i].childNodes[0].nodeValue;
    		
          }
          else {
           	itemTitle = "RSS feed missing or unavailable";
    		itemLink = "";
    		itemDesc = "";
          }
         
         if (i % 2 > 0)
         {
         	tempcolor = "#eddec1";
         } else {
       	tempcolor = "#f2ebdc";
        }
                    
         html = html + "<div class='item' style='background-color:" + tempcolor + ";'><div class='title'>"+itemTitle+"</div><div class='pubdate'>"+itemPubDate+"</div><div class='description'>"+itemDesc+"</div></div>";
        }
      }
    
      el.innerHTML = html;
      html = null;
      el = null;
      req = null;
     	
    }
    
    
    
     </script>
    </head>
    <body onload="loadRSSFeed();">
    <div class="headerBackground"><img src="img/mobileHeader.gif" style="height:50px;" alt="" /></div>
    
    	<div class="mobilemain">
    
    		<div id="content" style="margin-left:-10px;">
     
    		</div>          
    
    	</div>
    </div>
      
    </body>
    </html>

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: RSS feed in WRT Widget not working on device, but does in desktop browser

    Hi captain_planet,

    just guessing: are you using a public IP/URL to access the remote XML (e.g.: can you access the RSS by typing its URL in the phone's Web browser)?

    Pit

Similar Threads

  1. WRT Widget registry in Browser 7.1
    By jeonsinho in forum Symbian
    Replies: 0
    Last Post: 2009-12-03, 06:24
  2. Lookup device type for tag as rss feed tag
    By sim0nha in forum Symbian
    Replies: 7
    Last Post: 2009-07-13, 09:29
  3. Why does my rss feed crash my widget
    By tbertram in forum Symbian
    Replies: 4
    Last Post: 2009-05-29, 13:26
  4. Replies: 7
    Last Post: 2009-05-27, 06:27
  5. My widget stopped working. Feed read timeout
    By miklos.szanyi@gmail.com in forum Widsets Development
    Replies: 0
    Last Post: 2009-01-23, 10:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×