This is a migrated thread and some comments may be shown as answers.

Bind to remote xml

6 Answers 291 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 18 Nov 2011, 05:13 PM
How do I configure the widget to bind to this XML?

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: {
                url: "http://www.google.com/ig/api?weather=hamilton",
                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

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Nov 2011, 05:20 PM
or:
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/
0
Atanas Korchev
Telerik team
answered on 18 Nov 2011, 05:32 PM
Hi Steve,

 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,

Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Nov 2011, 05:34 PM
Aw darn, will it be supported for release?...or shortly after perhaps?

Thanks,
Steve
0
Accepted
Atanas Korchev
Telerik team
answered on 18 Nov 2011, 06:01 PM
Hello 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,

Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Nov 2011, 06:43 PM
Whoops dateType :)

Thanks for trying, I'll consume it on my own service and feed it back as JSON instead then
0
Tom
Top achievements
Rank 1
answered on 28 Apr 2012, 05:47 PM
Steve/Atanas, 

I was wondering since this thread was created if KendoUI ever supported binding remote XML data?

Thanks, 

Tom
Tags
Data Source
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Atanas Korchev
Telerik team
Tom
Top achievements
Rank 1
Share this question
or