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

XML on datasource not working...

3 Answers 138 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Gabriel
Top achievements
Rank 1
Gabriel asked on 11 Dec 2011, 03:25 AM
Here is my test HTML page (only relevant to the problem):
<ul id="books"></ul>
 
            <script id="template" type="text/x-kendo-template">
                <li class="book">
                    <h3>#= title #</h3>
                    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: {
                            read: "filters.xml"
                        },
                        schema: {
                            // specify the the schema is XML
                            type: "xml",
                            data: "/Filters/Filter",
                            model: {
                                fields: {
                                    title: "title/text()",
                                    author: "@Id",
                                    url: "info/text()"
                                }
                            }
                        },
                        change: onChage
                    });
 
                    dataSource.read();
                });
            </script>

and here is my XML file:
<?xml version="1.0"?>
-<Filters> -<Filter Id="drwho"> <Collection>drwho</Collection> <Title>Favourite Doctor</Title> <Info>link_to_popup_info.html</Info> <Image>drwho.png</Image> </Filter> -<Filter Id="poo"> <Collection>poop</Collection> <Title>smell that?</Title> <Info>link_to_popup_info.html</Info> <Image>poop.png</Image> </Filter> </Filters>

It doesn't work. I've also noticed if I overwrite the books.xml file in the sample line by line it will work. Other than that (which is stupid) I have no idea why the code refuses to run. The code is from the xml-data.html file.

Any ideas?

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 12 Dec 2011, 12:30 PM
Hello Gabriel,

<?xml version="1.0"?>
-<Filters> -<Filter Id="drwho"> <Collection>drwho</Collection> <Title>Favourite Doctor</Title> <Info>link_to_popup_info.html</Info> <Image>drwho.png</Image> </Filter> -<Filter Id="poo"> <Collection>poop</Collection> <Title>smell that?</Title> <Info>link_to_popup_info.html</Info> <Image>poop.png</Image> </Filter> </Filters>

The dashes in the XML file are confusing the datasource parsing. 

Regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gabriel
Top achievements
Rank 1
answered on 13 Dec 2011, 12:20 AM
Thanks. I copied the XML data when viewing in IE. There are not dashes in the actual file. Any ideas?
0
Petyo
Telerik team
answered on 13 Dec 2011, 09:56 AM
Hello Gabriel,

 The fields definition are case sensitive. In your case, it should be something like

fields: {
                     title: "Title/text()",
                     author: "@Id",
                     url: "info/text()"
                 }

All the best,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Gabriel
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Gabriel
Top achievements
Rank 1
Share this question
or