PDA

View Full Version : Problem with XML



DJ JJ
28 Jun 2011, 9:09 AM
Hi, I'm learning Sencha Touch. I created a simple project where I read some information from a local XML file, but it doesn't work. There is this error, but I can't understand why:

Uncaught TypeError: Cannot read property 'length' of undefined sencha-touch-debug.js:7212

this is my code:



<!DOCTYPE HTML>
<html>
<head>
<title>Pagina di prova</title>
<content-type: "text/xml">
<link rel="stylesheet" href="sencha-touch-1.1.0/resources/css/sencha-touch.css" type="text/css">
<script src="sencha-touch-1.1.0/sencha-touch-debug.js" type="text/javascript"></script>
<script type="text/javascript">
Ext.setup({
onReady: function() {
Ext.regModel('User', {
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'email', type: 'string'}]
});
var store = new Ext.data.Store({
storeId: 'userStore',
model: 'User',
proxy: {
type: 'ajax',
url: 'prova.xml',
reader: {
type: 'xml',
root: 'users',
record: 'user'
}
}
});
store.load();
var panel = new Ext.Panel({
fullscreen: true,
items: [{
xtype: 'list',
store: store,
itemTpl: "\"{name}\" &lt;{email}&gt;",
singleSelect: true
}]
});
}
});
</script>
</head>
<body>
</body>
</html>



and this is the XML file:



<?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>

bharatn
28 Jun 2011, 10:25 AM
Dj, it works for me. Did you try with ST 1.1 - if not i would suggest get the latest?

I would also remove the "<content-type: "text/xml">" from the html file.

DJ JJ
29 Jun 2011, 8:57 AM
I'm using the last version of Sencha Touch, but it doesn't work. Did you try it?