fetching xml and using dom data. (orkut application)

2 views
Skip to first unread message

observer247

unread,
Jun 14, 2008, 4:01:40 AM6/14/08
to OpenSocial - OpenSocial Application Development
My module is "opensocial-0.7" based and I am building an orkut
application.

I am trying to fetch an xml file and then try to use the data. But
facing some problems:

I am using this code to the url:

var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.DOM;
gadgets.io.makeRequest(url, url_response, params);

Now are there are simpler functions to go through the dom object. For
eg: the function getElementsByTagName cannot be used.

It is pretty tedious to go through every node using childNodes and
nodeName.

Can someone please point me to an example code which uses data from an
xml file using the ContentType DOM. In google gadgets, I was using
_IG_FetchXmlContent which do not seem to work here.

Thanks for reading.

observer247

unread,
Jun 14, 2008, 4:23:49 PM6/14/08
to OpenSocial - OpenSocial Application Development
can someone pls help ?

Aakash Bapna

unread,
Jun 14, 2008, 4:48:03 PM6/14/08
to opensoc...@googlegroups.com
Hi,
You have to go through the XML content by your own methods.
if you find tedious going through each element using DOM give JSON a try.. anyways this link might be helpful to you- http://code.google.com/apis/opensocial/articles/makerequest.html#contenttypes-dom

Thanks
 
~@@k@sh
http://aakash-bapna.blogspot.com





> Date: Sat, 14 Jun 2008 13:23:49 -0700
> Subject: [OpenSocial] Re: fetching xml and using dom data. (orkut application)
> From: pre...@gmail.com
> To: opensoc...@googlegroups.com

Arne Roomann-Kurrik (Google)

unread,
Jun 19, 2008, 1:55:40 PM6/19/08
to OpenSocial - OpenSocial Application Development
Honestly, I don't find much use in fetching items as DOM. You can
just as easily fetch text and assign it to innerHTML (as long as the
text is trusted not to be malicious!) of a parent element.

However, you can still use getElementsByTagName on a DOM request. I
just executed the following in orkut:

function response(data) {
alert(data.data.getElementsByTagName("menu")
[0].getAttribute("title"));
};
var url = "http://doc.examples.googlepages.com/breakfast-data.xml";

var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.DOM;
gadgets.io.makeRequest(url, response, params);

Which alerted "Breakfast Menu".

Hope this helps,
~Arne
Reply all
Reply to author
Forward
0 new messages