1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    59
    Vote Rating
    0
    jamone is on a distinguished road

      0  

    Default Answered: MVC and reading XML data

    Answered: MVC and reading XML data


    MVC and reading XML data

    I looked at the MVC account manager demo application in the Application Architecture and appreciated it, and it worked using the json data format, I wanted to switch to an XML data format and get the following error.

    Error:
    XML data not found in the response, ext-debug.js:8077


    app/store/Users.js

    Ext.define('AM.store.Users', {
    extend: 'Ext.data.Store',
    model: 'AM.model.User',
    autoLoad: true,

    proxy: {
    type: 'ajax',
    api: {
    read: 'data/users.xml',
    update: 'data/updateUsers.xml'
    },
    reader: {
    type: 'xml',
    root: 'users',
    record: 'user',
    successProperty: 'success'
    }
    }
    });

    app/model/User.js

    Ext.define('AM.model.User', {
    extend: 'Ext.data.Model',
    fields: ['id', 'name', 'email']
    });

    app/data/users.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <success>true</success>
    <users>
    <user>
    <id>1</id>
    <name>Ed</name>
    <email>ed@sencha.com</email>
    </user>
    <user>
    <id>2</id>
    <name>Tommy</name>
    <email>tommy@sencha.com</email>
    </user>
    </users>

    How would I get this account manager app to work with an XML file?

    Thanks in advance.

  2. Your XML is invalid. The first tag (success) must not close until the end of the XML. Try moving the success tag inside your users tag.

  3. #2
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,235
    Vote Rating
    7
    Answers
    55
    arthurakay has a spectacular aura about arthurakay has a spectacular aura about

      0  

    Default


    1. Use CODE tags next time you post sample code.

    2. What is the content-type of the response coming from the server? Is it "text/xml" or "application/xml"?

    From the API docs on Ext.data.reader.Xml:

    Code:
    Note: in order for the browser to parse a returned XML document, the Content-Type header in the HTTP response must be set to "text/xml" or "application/xml". This is very important - the XmlReader will not work correctly otherwise.
    Arthur Kay
    Solutions Engineer, Sencha Inc.

    Twitter | Sencha Chicago User Group

  4. #3
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,082
    Vote Rating
    112
    Answers
    454
    skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold skirtle is a splendid one to behold

      0  

    Default


    Your XML is invalid. The first tag (success) must not close until the end of the XML. Try moving the success tag inside your users tag.

Tags for this Thread