I am still working on my first gadget and noticed things work really different on live.com compared to spaces. If you want to load what I have so far and see what I mean, the manifest can be found at http://www.incendy.com/MyRSS/rssgadget3.xml
Basically the css is very different and also the function that rebuilds the list does not really work on Spaces and you have to manually refresh the page to get the new feed. Just curious if others have experienced this and have advice on what I should be doing differently.
The function getfeed gets called but the content seems to be cached on Spaces where it works fine on live.com!

Gadget behavior on spaces vs live.com?
johnvms
MedicineMan
It looks like Flickr uses a different "media" namespace than Soapbox (the sample code I posted was from parsing Soapbox RSS feeds). In this case, Flickr's thumbnail ("media:thumbnail") is under "item" directly rather than under "media:content" (that is, if you want to pull the thumbnail as your code seems, you should use "media:thumbnail" in your selectSingleNode() call rather than "media:content/media:thumbnail").
Also, a word of warning: I have had problems getting Firefox to parse XPaths with namespaces in them ("media:thumbnail" is prefixed by a namespace, "//rss/channel/item" is not) when the feed is pulled through the rss proxy. This is very odd, since the error is thrown from the Atlas compatibility layer. I have no idea why a compatibility layer would be needed to handle XPaths on Firefox, since Firefox arguably has a more robust and complete XML and XPath implementation than IE. Anyway, the upshot of this is that you need to pull your feeds using the generic proxy. BUT if you do that, you have to make sure your feeds are of type "text/plain" or you won't be able to retrieve them from Spaces. Spaces may have changed that restriction recently, but I haven't checked to fidn out.
Steve Jensen
Strange. I just checked out couple gadgets of my own that do the same thing to break the cache and they work just fine up on Spaces. I tested both the generic proxy and the RSS proxy and saw no difference. The only difference is that my gadgets pull apart the RSS feeds using XPaths while yours uses Start.Parser.RssParseResponse, so perhaps the caching is happening in the parser. Try some simple alert()-style debugging. In OnFeedReceived, do an alert(response.responseXML.documentElement.text); and copy the output for several refreshes (you can ctrl+c on the alert() message box). Save the output into different files and run a diff on them (using a tool like windiff, if you have it). If they're different but you're still getting the same output as if it's cached then something's going on in Start.Parser.RssParseResponse and it's time to look into parsing on your own :).
Here's a link to the w3c.org XPath spec. That's a little dry reading but it covers XPath syntax fairly well. You can also lookup the selectNodes() and selectSingleNode() methods for the javascript XML document as those are the functions you'll use to apply XPaths (the former returns an array of nodes that match the XPath, the latter returns only the first matching node).
Here's an example of code to parse an RSS feed using XPaths.
var
items = response.responseXML.documentElement.selectNodes("//rss/channel/item");if
(items != null && items.length > 0){
m_videoItems =
new Array(items.length); var len = Math.min(items.length, 25); for (var i = 0; i < len; i++){
var link = items[ i ].selectSingleNode("link").text; var guid = link.substring(link.indexOf("vid=") + 4); var imgSrc = items[ i ].selectSingleNode("media:content/media:thumbnail").attributes.getNamedItem("url").value; var title = items[ i ].selectSingleNode("title").text;}
}
irrdev
Thanks for your example code ToddOs! It helped me a lot.
But still I have the question, that where can I find a correct API reference documentation for the response.responseXML.documentElement, and for the classes,properties,methods related to it
Because I searched the msdn's HTML and DHTML reference and the msdn2's XmlNode reference , but neither matches 100%.
Kamen
Some bits:
Jurgita
vsarowatz
Thank you Todd0s! I do use the random link, however even with the random link spaces seems to cache the rss feed. I suppose I could get rid of this all together as long as I let the user know that once they refresh they will see the updated feed. Just thought is was weird that spaces did not update the content like I expected it to. As for the xml and xpath I am not too familiar:)
The one thing about css that really surprised me on live.com was my borders which are specific colors get overridden although they show exactly as I pictured on Spaces. Thanks again for the feedback, I really appreciate it!
magicalclick
tonn
Todd0sI am trying to use your example to parse the rss from flickr and show it but am having problems. I know the feed works, so it seems something is wrong in the area where I check for the items. If you have the time to take a look maybe it is something really obvious! Thank you!
function
GetFeed(){
var r = Web.Network.createRequest(Web.Network.Type.XML,
m_feedUrl,
{proxy:
"rss", numItems:m_numItems},OnFeedReceived);
r.execute();
}
function OnFeedReceived(response){
m_el.className = "main";
m_headlinesEl = document.createElement(
"ul");m_headlinesEl.className =
"rssList";m_el.appendChild(m_headlinesEl);
var items = response.responseXML.documentElement.selectNodes("//rss/channel/item");
if (items != null && items.length > 0)
{
m_videoItems = new Array(items.length);
var len = Math.min(items.length, 25);
for (var i = 0; i < len; i++)
{
var link = itemsli = document.createElement(
"li");li.className =
"rssItem";m_headlinesEl.appendChild(li);
var aEl = document.createElement("a");li.appendChild(aEl);
aEl.href = link;
aEl.target =
"top";aEl.innerHTML =
"<img src=" + imgSrc + ">";}
}
}
Pieneer
Did you just recently make the change Your browser may have cached the old code. In IE, you need to either stop and restart the browser or set it to always fetch the page (Tools->Options, General tab, Browsing History section, Settings in IE7, set "Check for new versions of stored pages" to "Every time I visit the webpage"). Firefox doesn't clear the cache on restart so you'll have to clear manually (Tools->Options, Privacy tab, Clear Now, uncheck everything but Cache). If you're sure you're seeing the correct code but it's still not behaving correctly even with the random bits then I have no clue what's going on. Adding random bits to smash the cache has always worked for me.
No idea on your border issue. I've mostly had problems with font sizing and list positioning, not so much with borders and colors/sizes.
TiKu
Samaritan
Another good reference:
http://www.w3schools.com/dom/default.asp
Ljhopkins