Results 1 to 3 of 3

Thread: MVC and reading XML data

  1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    59
    Vote Rating
    0
      0  

    Default 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 User arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,516
    Answers
    99
    Vote Rating
    77
      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.

  4. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    390
      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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •