3 messages in com.googlegroups.opensocial-api[OpenSocial] Re: opensocial applicati...
FromSent OnAttachments
dragosh23 Jul 2008 03:59 
yoichiro23 Jul 2008 04:26 
dragosh23 Jul 2008 06:39 
Subject:[OpenSocial] Re: opensocial application similar to a feed reader
From:yoichiro (yoic@eisbahn.jp)
Date:07/23/2008 04:26:00 AM
List:com.googlegroups.opensocial-api

Hi dragosh,

The calling of doc.loadXML() function will be refused because of security. Instead, you will be able to access the rss feed with gadgets.io.makeRequest() function. I think that you should see the following document:

[Fetching Remote Content - XML Example] http://code.google.com/apis/opensocial/docs/0.7/devguide.html#XML

On Jul 23, 7:59 pm, dragosh <andr@yahoo.com> wrote:

Hi! I'm trying to build a gadget that is like a feed reader, i give the url of the rss feed and i want to receive the rss feed (the xml file) and parse it my self , in order to display the news how i want to. The problem i am having is related to the reading of the rss feed. I have the following javascript code for opening the file :

----------------------------------------- function xmlNewDocument(rootTagName, namespaceURL) { if (!rootTagName) rootTagName = ""; if (!namespaceURL) namespaceURL = "";

if (document.implementation && document.implementation.createDocument) { // This is the W3C standard way to do it return document.implementation.createDocument(namespaceURL, rootTagName, null);}

else { // This is the IE way to do it // Create an empty document as an ActiveX object // If there is no root element, this is all we have to do var doc = new ActiveXObject("MSXML2.DOMDocument");

// If there is a root tag, initialize the document if (rootTagName) { // Look for a namespace prefix var prefix = ""; var tagname = rootTagName; var p = rootTagName.indexOf(':'); if (p != -1) { prefix = rootTagName.substring(0, p); tagname = rootTagName.substring(p+1);

}

// If we have a namespace, we must have a namespace prefix // If we don't have a namespace, we discard any prefix if (namespaceURL) { if (!prefix) prefix = "a0"; // What Firefox uses}

else prefix = "";

// Create the root element (with optional namespace) as a // string of text var text = "<" + (prefix?(prefix+":"):"") + tagname + (namespaceURL ?(" xmlns:" + prefix + '="' + namespaceURL +'"') :"") + "/>"; // And parse that text into the empty document doc.loadXML(text);

} return doc; } };

function xmlLoad(url) { // Create a new document with the previously defined function var xmldoc = xmlNewDocument("",""); xmldoc.async = false; // We want to load synchronously alert(xmldoc.load(url)); // Load and parse return xmldoc; // Return the document

};

function showFeed() { var myfile = xmlLoad(theFile); // theFile = url of the feed given as input alert(myfile.text);

}

-------------------

     The showFeed function is called when clicking on a button. The gadget code is hosted on an account on iGoogle, written in Google Gadget Editor and i am testing it in orkut sandbox on my profile. The problem is that it won't open the file. If i hardcode the file to be read as a test.xml hosted also on iGoogle....then the gadget is able to see it but it still doesn't open anything for me. If i give a url from the web it doesn't do anything at all. An alert message put after the load function works in the case of the local file but not in the case of a file from the web.     Can anyoane help me, tell what i doing wrong, give me an idee, something...     Thank you!