Hello,
I have encountered problems with widgets when parsing atom feeds. I have been using the usual javascript method "getElementsByTagName()" to get the tags elements but some tags are partially or entirely not returned. The code below doesn't get the titles tags. At first I thought that the problems only occurred with tags using attributes but this new feed for testing has tags attributes like "summary" which get rendered properly. I am bit puzzled about this issue. Is it a problem with the widget engine or an error in the code ? I have previously made some other tests, the same code not working on widgets was working on firefox when parsing atom feeds.
Thanks in advance for your answers,
Patrice
Here is the code:
Javascript :
CSS:Code:var ajaxRequest = null; var url = 'http://feeds.sophos.com/en/atom1_0-sophos-security-news.xml'; window.onload = doRequest; function doRequest() { if (null == ajaxRequest) { ajaxRequest = new XMLHttpRequest(); } ajaxRequest.onreadystatechange = ReqStateChange; ajaxRequest.open( 'GET', url, true ); ajaxRequest.send( null ); } // state handler function ReqStateChange() { // if request ready if ( ajaxRequest.readyState == 4 ) { if ( ajaxRequest.status == 200 ) { loadContent( ajaxRequest ); } else { alert( "Error, could not load content" ); } } } function loadContent(argReq) { var XMLData = null; var title; var id; var summary; XMLData = argReq.responseXML.documentElement; if (XMLData != null) { var titleNodes = XMLData.getElementsByTagName('title'); var idNodes = XMLData.getElementsByTagName('id'); var summaryNodes = XMLData.getElementsByTagName('summary'); for (i = 0; i < titleNodes.length; i++) { title += titleNodes[i].childNodes[0].nodeValue + '<br\>'; } for (i = 0; i < idNodes.length; i++) { id += idNodes[i].childNodes[0].nodeValue + '<br\>'; } for (i = 0; i < summaryNodes.length; i++) { summary += summaryNodes[i].childNodes[0].nodeValue + '<br\>'; } } document.getElementById("content").innerHTML = "<strong>Titles: </strong><br\>" + title + "<br\>" + "<strong>IDs: </strong><br\>" + id + "<strong>Summaries: </strong><br\>" + summary; }
XHTML:Code:#content { font-size: 12px; padding-top: 10px; display: display; }
Info.plist:Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="index.css" /> <script type="text/javascript" src="atom-widget.js"></script> </head> <body> <div id="content"></div> </body> </html>
Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/NOKIA_COM_1/DTDs/plist-1.0.dtd"> <plist version="1.0"> <dict> <key>DisplayName</key> <string>atom widget</string> <key>Identifier</key> <string>com.widget.nokia</string> <key>MainHTML</key> <string>index.html</string> <key>AllowNetworkAccess</key> <true /> </dict> </plist>

Reply With Quote



