http://www.google.com/ig/api?weather=hamilton,ON
This is my definition so far...
$(document).ready(
function
() {
function
onChange() {
$(
"#weather-container"
).html(kendo.render(template,
this
.view()));
}
// create a template using the above definition
var
template = kendo.template($(
"#dashwidget-weather-template"
).html());
var
dataSource =
new
kendo.data.DataSource({
transport: {
// specify the XML file to read. The same as read: { url: "books.xml" }
read: {
dateType:
"xml"
}
},
schema: {
// specify the the schema is XML
type:
"xml"
,
// the XML element which represents a single data record
data:
"/weather/current_conditions"
,
// define the model - the object which will represent a single data record
model: {
fields: {
condition:
"condition/text()"
,
temp:
"temp_c/text()"
}
}
},
change: onChange
});
dataSource.read();
});
6 Answers, 1 is accepted
transport: {
// specify the XML file to read. The same as read: { url: "books.xml" }
read: {
url:
"http://www.google.com/ig/api"
,
dateType:
"xml"
,
data: {
weather:
"Hamilton,ON"
}
}
},
http://jsfiddle.net/fQJ2D/1/
Binding to cross domain XML is not currently supported. You can download the XML only with an XMLHTTPRequest which supports cross origin resource sharing (CORS). There is of course JSONP which however will not work with XML for obvious reasons. You can check this blog post which explains this in more detail.
Regards,
the Telerik team
Thanks,
Steve
Does this web server have this http header enabled - Access-Control-Allow-Origin: * ?
If yes you can use it even now if you fix the typo - dateType should be dataType. You have also included mockjax which probably prevents all ajax requests from happening.
If it doesn't support the required HTTP header we can't do anything. You would need to create a server side proxy.
I ran a few tests and it seems it doesn't support access-control-allow-origin at the time being.
All the best,
the Telerik team
Thanks for trying, I'll consume it on my own service and feed it back as JSON instead then
I was wondering since this thread was created if KendoUI ever supported binding remote XML data?
Thanks,
Tom