Okay, after doing some more research I am pretty sure I need associated models to achieve this. After writing some more code toward this end I have run into an interesting wall. I am expecting it's a simple mistake.
First of all I changed the <options> and <option> tags in the xml to <answers> and <answer> to prevent confusion with some other variables I was using in my Controller.
Here is the new model structure:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<course><title></title>
<pages>
<page>
<id>01</id>
<type>content</type>
<title>Title 1</title>
<url>path/to/file.html</url>
<answers>
<answer>Answer 1</answer>
<answer>Answer 2</answer>
<answer>Answer 3</answer>
<answer>Answer 4</answer>
</options>
</page>
<page>
<id>02</id>
<type>content</type>
<title>Title 2</title>
<url>path/to/file.html</url>
<answers>
<answer>Answer 1</answer>
<answer>Answer 2</answer>
<answer>Answer 3</answer>
<answer>Answer 4</answer>
</options>
</page>
</pages>
</course>
I created a new model with the fields needed to read the answers and I had to create a proxy for it because the data wasn't being read in otherwise. (This might be my problem, I am not sure). I also read in another thread that you need to create a field in the parent Model that matches the associated model. (This also could be a problem, not sure).
PHP Code:
app.models.answers = Ext.regModel('answers', {
fields: [
{name: 'answer', type: 'string' },
],
proxy: {
type: 'ajax',
url : 'assets/xml/course.xml',
reader: {
type: 'xml',
//root: 'answers',
record: 'answer'
},
},
});
app.models.pages = Ext.regModel('pages', {
fields: [
{name: 'id', type: 'string' },
{name: 'type', type: 'string' },
{name: 'title', type: 'string' },
{name: 'url', type: 'string' },
{name: 'question', type: 'string' },
{name: 'answers', type: 'auto' },
{name: 'correct', type: 'int' },
{name: 'tries', type: 'int' },
],
hasMany: {model: 'answers', name: 'answers'},
});
Now in my controller I create a new answers object using the record.answers() getter function that is auto generated. when I look at the new answers.data it's an array of objects. If I drill down to the data with answers.data.items[0] I can see the answer field but it is blank text, but the pages_id shows the correct id from the <page> object. However, if I drill to answers.data.items[0].raw it returns the raw xml properly. <answer>Answer 1</answer>. What this tells me is the data is being read properly, but the answer field isn't being populated with the text in the <answer> tag.
Any help out there?