-
24 Aug 2011 6:28 AM #1
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.
-
Best Answer Posted by skirtle
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.
-
24 Aug 2011 9:16 AM #2
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.
-
27 Aug 2011 12:09 AM #3
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.


Reply With Quote