Forum /
Sencha Touch 1.x Forums /
Sencha Touch 1.x: Q&A /
Unanswered: Uncaught TypeError: Cannot read property 'length' of undefined reading xml in a list
Unanswered: Uncaught TypeError: Cannot read property 'length' of undefined reading xml in a list
this is my code:
Ext.setup({
onReady : function () {
Ext.regModel('User', {
fields : ['id', 'name', 'email']
});
var store = new Ext.data.Store({
model : 'User',
autoLoad : true,
proxy : {
type : 'ajax',
url : 'users.xml',
reader : {
type : 'xml',
root : 'users',
record : 'user'
}
}
});
var list = new Ext.List({
fullscreen : true,
singleSelect : true,
store : store,
itemTpl : '{id} {name} {email}',
centered : true,
emptyText : 'No XML'
});
list.show();
}
});
this is my xml
<?xml version="1.0" encoding="UTF-8"?>
<user>
<id>1</id>
<name>Ed Spencer</name>
<email>ed@sencha.com</email>
</user>
<user>
<id>2</id>
<name>Abe Elias</name>
<email>abe@sencha.com</email>
</user>
this is mi index
<!DOCTYPE html>
<html>
<head>
<title>Hola Mundo!!!</title>
<script src="lib/sencha/sencha-touch.js" type="text/javascript"></script>
<link href="lib/sencha/sencha-touch.css" rel="stylesheet" type="text/css" />
<script src="app/xml.js" type="text/javascript"></script>
</head>
<body></body>
</html>
Sencha - Senior Forum Manager
You have root : 'users' but no users tag in your XML.
error persist
error persist
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user>
<id>1</id>
<name>Ed Spencer</name>
<email>ed@sencha.com</email>
</user>
<user>
<id>2</id>
<name>Abe Elias</name>
<email>abe@sencha.com</email>
</user>
</users>
Hi, Were you able to solve this problem. I am too facing the same issue. Can someone please help me?
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us