PDA

View Full Version : Ext.data.Store and XML



Tdounih
15 Jul 2011, 1:31 AM
Hi,

I'm new with this so sorry if I'm asking stupid questions... :)

I'm trying to get images from xml feed but I don't know how to do it.
Maybe after that I'll try to add carousel to images.

I have tried many combinations from different samples but I just don't get much far from this.
With store.load(); I got xml to the game but now I don't know how to print those xml fields.

Also Javascript debugger in Safari comments this now:
TypeError: Result of expression 'a' [undefined] is not an object.

I hope someone could give me some good tips how to continue with this.
Thanks!

Here is my sample index.html and test.xml I'm using.



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>XML Test</title>

<script src="lib/touch/sencha-touch.js" type="text/javascript"></script>
<link href="lib/touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

Ext.regModel('Page', {
fields: ['number', 'image_url']
});

var store = new Ext.data.Store({
model: 'Page',
proxy: {
type: 'ajax',
url : 'test.xml',
reader: {
type: 'xml',
record: 'page'
}
}
});
store.load();

</script>

</head>
<body></body>
</html>




<?xml version="1.0" encoding="UTF-8"?>
<page>
<number>1</number>
<image_url>image1.jpg</image_url>
</page>
<page>
<number>2</number>
<image_url>image2.jpg</image_url>
</page>
<page>
<number>3</number>
<image_url>image3.jpg</image_url>
</page>
<page>
<number>4</number>
<image_url>image4.jpg</image_url>
</page>