Reputation: 895
I'm using YQL to make cross-domain REST requests in jQuery. I'm getting the XML response I want as a key-value pair in the JSON response.
The request I'm making to is:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22https%3A%2F%2Fwww.quickbase.com%2Fdb%2Fmain%3Fact%3DAPI_Authenticate%26username%3Dsomething%40intuit.com%26password%3Dsomething%26hours%3D24%22&format=xml&callback=?
The response I'm getting back is:
Now, my question is, how do I parse results[0] as an XML document? Any help would be greatly appreciated.
Thanks and Regards, Ashwin
Upvotes: 2
Views: 1157
Reputation: 895
This worked for me.
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(results[0],"text/xml");
}
else
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(results[0]);
}
Upvotes: 0
Reputation: 2659
Try this
var xml = $.parseXML( results[0] );
$(xml).find("qdbapi").each(
function() {
var action = $(this).attr("action");
});
Upvotes: 1