Binding to remote XML Data

2 posts, 0 answers
  1. Gabe Silvarajoo
    Gabe Silvarajoo avatar
    13 posts
    Member since:
    Apr 2009

    Posted 13 Apr 2012 Link to this post

    Dear Kendo UI Team,

    I have been studying the KendoUI Web examples and currently having problems getting data from a remote XML feed. Here's the example that I'm refering to Binding to XML Data and below is my code. I simply replace the source from local to Books.xml on the demo site.

    Code:
    <ul id="books"></ul>
     
                <script id="template" type="text/x-kendo-template">
                    <li class="book">
                        <a href="#= url #">
                            <h3>#= title #</h3>
                        </a>
                        by #= author #
                    </li>
                </script>
     
                <script>
                    $(document).ready(function () {
                        function onChage() {
                            $("#books").html(kendo.render(template, this.view()));
                        }
     
                        // create a template using the above definition
                        var template = kendo.template($("#template").html());
     
                        var dataSource = new kendo.data.DataSource({
                            transport: {
                                // specify the XML file to read. The same as read: { url: "books.xml" }
                                read: "http://demos.kendoui.com/content/web/datasource/books.xml"
                            },
                            schema: {
                                // specify the the schema is XML
                                type: "xml",
                                // the XML element which represents a single data record
                                data: "/books/book",
                                // define the model - the object which will represent a single data record
                                model: {
                                    // configure the fields of the object
                                    fields: {
                                        // the "title" field is mapped to the text of the "title" XML element
                                        title: "title/text()",
                                        // the "author" field is mapped to the text of the "author" XML element
                                        author: "author/text()",
                                        // the "url" field is mapped to the text of the "url" XML element
                                        url: "url/text()",
                                        // the "cover" field is mapped to the "id" attribute of the "book" XML element
                                        cover: "@cover"
                                    }
                                }
                            },
                            change: onChage
                        });
     
                        dataSource.read();
                    });
                </script>

    When I load the page, I don't get any data. Also, how can I see errors? Is there some code examples to display errors? Please advice. Thanks.

    Gabe
  2. Hari
    Hari avatar
    10 posts
    Member since:
    Oct 2012

    Posted 07 Dec 2012 Link to this post

    Hi,
    Were you able to resolve your issue? we are trying to set an XML Document as datasource for Kendo Tree view control and struck there. Can you help us?
Back to Top