Thank you for reporting this bug. We will make it our priority to review this report.
  1. #11
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    bobbaluba is on a distinguished road

      0  

    Default


    I can't get it to work either. Is there a simple example somewhere?

  2. #12
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    bobbaluba is on a distinguished road

      0  

    Default Simple example

    Simple example


    Figured it out some days ago, here's a pretty simple example for the rest of you:

    It doesn't do anything interesting, just load the xml then print the name of the first author.
    To access the nested elements use something like this

    store.getAt(0).books().each(function(book){
    console.log(book);
    });

    index.js
    Code:
    var App = new Ext.Application({
        name: 'Books',
        useLoadMask: true,
        launch: function () {
    	
    	    Ext.regModel('Book', {
                idProperty: 'name',
                fields: [
                    { name: 'name', type: 'string' },
                ],
    			belongsTo: 'Author',
    			proxy: {
    				type: 'memory',
    				reader: {
    					type: 'xml',
    					root: 'books',
    					record: 'book'
    				}
    			}
            });
    
            Ext.regModel('Author', {
                idProperty: 'name',
                fields: [
                    { name: 'name', type: 'string' },
                ],
    			hasMany: [
    				{
    					model : 'Book',
    					name: 'books',
    				}
    			]
            });
    		
    		store = new Ext.data.Store({
    			model: 'Author',
    			proxy: {
    				type: 'ajax',
    				url: './books.xml',
    				reader: {
    					type: 'xml',
    					record: 'author',
    					root: 'authors'
    				}			
    			}
    		});
    		
    		store.load();
    		
    		content = new Ext.form.FormPanel({
    			items:[
    				{
    					xtype:'textfield',
    					name: 'name',
    					label:'Author: '
    				}
    			]
    		});
    		
            Books.views.viewport = new Ext.Panel({
                fullscreen: true,
                layout: 'card',
                items: [
                    content
                ]
            });
    
    	//log the books to console to prove they were loaded
                setTimeout(function() {
    		content.load(store.getAt(0));
    		store.getAt(0).books().each(function(book){
    			console.log(book);
    		});
    	}, 1000);
        }
    });
    XML:
    Code:
    <authors>
    	<author>
    		<name>Author 1</name>
    		<books>
    			<book>
    				<name>Book</name>
    			</book>
    			<book>
    				<name>Book2</name>
    			</book>
    		</books>
    	</author>
    	<author>
    		<name>Author 2</name>
    		<books>
    			<book>
    				<name>Book3</name>
    			</book>
    			<book>
    				<name>Book4</name>
    			</book>
    		</books>
    	</author>
    </authors>
    I could have tidied the code up a bit, but I'm working on a project and don't have time for that.

  3. #13
    Sencha User
    Join Date
    Mar 2011
    Posts
    6
    Vote Rating
    0
    niktw is on a distinguished road

      0  

    Default


    is it possible such a struct to parce ?


    <xxx> <author name="Author 1"> <book name="Book1"/> <book name="Book2"/> </author> <author name="Author 2"> <book name="Book1"/> <book name="Book2"/> </author> </xxx>

  4. #14
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    With 2.0 just around the corner, I've added this to its backlog to make sure this happens. Almost all of our efforts are focused on 2.x at the moment so it should be a relatively simple thing to drop in
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  5. #15
    Sencha User
    Join Date
    Jul 2011
    Posts
    52
    Vote Rating
    0
    jameshenderson is on a distinguished road

      0  

    Default Please provide a complete working example for nested XML

    Please provide a complete working example for nested XML


    Please help, I am very depressed, I am already late on a SenchaTouch project and it must be finished by tomorrow. I have spent all weekend working on a nested XML feed and I cannot for the life of me get anything to return from the nested sections.


    I was hoping you could please please please give a complete working example?


    I have searched and searched but cannot find a single example anywhere.


    Taking your example further, I have this:


    Ext.regModel('Book',{
    fields:[
    {name:'bookname',type:'string'},
    {name:'pages',type:'int'},
    {name:'score',type:'int'}
    ],
    proxy: {
    type: 'memory',
    reader: {
    type: 'xml',
    root: 'books',
    record: 'book'
    }
    }
    });


    Ext.regModel('User',{
    fields:[
    {name:'userid',type: 'int'},
    {name:'username',type:'string'},
    {name:'books',type:'string'}
    ],
    //hasMany: {model: 'Book', name: 'books'},
    proxy: {
    type: 'ajax',
    url : urlRizlabProjects,
    reader: {
    type: 'xml',
    root: 'users',
    record: 'user'
    }
    }
    });








    You are free to completely change everything below but this is roughly what I normally do:




    var storage7 = new Ext.data.Store({
    model: 'User',
    listeners: {
    datachanged: function(){
    storage7.each(function(rec){


    alert(rec.get('username')); //this bit works


    //but how do I access the books here please?????????????????????????


    });
    }
    }
    });






    thank you so much - I have tried to find information about memory records but have got nothing, plus a very long list of pages with people asking about nested xml.

  6. #16
    Sencha User
    Join Date
    Jul 2011
    Posts
    52
    Vote Rating
    0
    jameshenderson is on a distinguished road

      0  

    Default I worked it out now...

    I worked it out now...


    Must have been feeling really tired, and didn't properly try out bobbaluba's example above - it works! I will bookmark this url and post it whenever I see other lost soul's trying to get this working

  7. #17
    Sencha User
    Join Date
    Mar 2009
    Posts
    1
    Vote Rating
    0
    vrutberg is on a distinguished road

      0  

    Default


    Am I correct to assume that parsing the following XML isn't possible with Sencha Touch 1.0? Seeing as the <section> tags and <production> tags don't have an element surrounding them, which would correspond to the root parameter when you create an XMLReader?

    Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <production>
      <productiondate>2011-09-18</productiondate>
      <updated>2011-09-19 13:03:00</updated>
      <section>
        <header>September 2011</header>
        <production>
            <header>Profit</header>
            <prodvalue>1451</prodvalue>
            <plandiff>-20</plandiff>
        </production>
        <production>
            <header>Hours</header>
            <prodvalue>1384</prodvalue>
            <plandiff>-55</plandiff>
        </production>
        <production>
            <header>Cost</header>
            <prodvalue>1203</prodvalue>
            <plandiff>-147</plandiff>
        </production>
      </section>
      <section>
        <header>Development</header>
        <production>
            <header>KA2</header>
            <prodvalue>0.0</prodvalue>
            <plandiff>-1.7</plandiff>
        </production>
        <production>
            <header>KA3</header>
            <prodvalue>1.2</prodvalue>
            <plandiff>-0.4</plandiff>
        </production>
        <production>
            <header>KK2</header>
            <prodvalue>10.8</prodvalue>
            <plandiff>-0.4</plandiff>
        </production>
        <production>
            <header>KK3</header>
            <prodvalue>13.3</prodvalue>
            <plandiff>-1.2</plandiff>
        </production>
        <production>
            <header>KK4</header>
            <prodvalue>13.9</prodvalue>
            <plandiff>-1.5</plandiff>
        </production>
        <production>
            <header>KS</header>
            <prodvalue>1.7</prodvalue>
            <plandiff>1.7</plandiff>
        </production>
        <production>
            <header>SA</header>
            <prodvalue>0.0</prodvalue>
            <plandiff>0.0</plandiff>
        </production>
        <production>
            <header>SK</header>
            <prodvalue>12.3</prodvalue>
            <plandiff>1.3</plandiff>
        </production>
        <production>
            <header>MK3</header>
            <prodvalue>11.1</prodvalue>
            <plandiff>0.6</plandiff>
        </production>
        <production>
            <header>BUV</header>
            <prodvalue>11.3</prodvalue>
            <plandiff>0.4</plandiff>
        </production>
        <production>
            <header>ANR</header>
            <prodvalue>8.2</prodvalue>
            <plandiff>2.4</plandiff>
        </production>
      </section>
      <section>
        <header>Ores</header>
        <production>
            <header>Sweden</header>
            <prodvalue>72.6</prodvalue>
            <plandiff>-3.3</plandiff>
        </production>
        <production>
            <header>Norway</header>
            <prodvalue>56.5</prodvalue>
            <plandiff>7.3</plandiff>
        </production>
      </section>
      <section>
        <header>Train</header>
        <production>
            <header>Sweden</header>
            <prodvalue>6</prodvalue>
            <plandiff>-4</plandiff>
        </production>
        <production>
            <header>Norway</header>
            <prodvalue>4</prodvalue>
            <plandiff>-1</plandiff>
        </production>
      </section>
    </production>

  8. #18
    Sencha User swarnendude's Avatar
    Join Date
    Jul 2009
    Location
    Kolkata, India
    Posts
    117
    Vote Rating
    1
    swarnendude is on a distinguished road

      0  

    Default


    The hasMany associations keep giving only one result for the child data for XML. Isn't this issue still solved with ST 1.1? Using all the ideas given here, I get only one association data.
    Swarnendu
    Co-founder & Lead Architect @ Innofied

    ------------------
    I blog at http://www.swarnendude.com

  9. #19
    Sencha Premium Member
    Join Date
    Jan 2012
    Posts
    10
    Vote Rating
    1
    youdonotexist is on a distinguished road

      0  

    Default


    Quote Originally Posted by vrutberg View Post
    Am I correct to assume that parsing the following XML isn't possible with Sencha Touch 1.0? Seeing as the <section> tags and <production> tags don't have an element surrounding them, which would correspond to the root parameter when you create an XMLReader?

    Code:
    <?xml version="1.0" encoding="iso-8859-1" ?>
    <production>
      <productiondate>2011-09-18</productiondate>
      <updated>2011-09-19 13:03:00</updated>
      <section>
        <header>September 2011</header>
        <production>
            <header>Profit</header>
            <prodvalue>1451</prodvalue>
            <plandiff>-20</plandiff>
        </production>
        <production>
            <header>Hours</header>
            <prodvalue>1384</prodvalue>
            <plandiff>-55</plandiff>
        </production>
        <production>
            <header>Cost</header>
            <prodvalue>1203</prodvalue>
            <plandiff>-147</plandiff>
        </production>
      </section>
      <section>
        <header>Development</header>
        <production>
            <header>KA2</header>
            <prodvalue>0.0</prodvalue>
            <plandiff>-1.7</plandiff>
        </production>
        <production>
            <header>KA3</header>
            <prodvalue>1.2</prodvalue>
            <plandiff>-0.4</plandiff>
        </production>
        <production>
            <header>KK2</header>
            <prodvalue>10.8</prodvalue>
            <plandiff>-0.4</plandiff>
        </production>
        <production>
            <header>KK3</header>
            <prodvalue>13.3</prodvalue>
            <plandiff>-1.2</plandiff>
        </production>
        <production>
            <header>KK4</header>
            <prodvalue>13.9</prodvalue>
            <plandiff>-1.5</plandiff>
        </production>
        <production>
            <header>KS</header>
            <prodvalue>1.7</prodvalue>
            <plandiff>1.7</plandiff>
        </production>
        <production>
            <header>SA</header>
            <prodvalue>0.0</prodvalue>
            <plandiff>0.0</plandiff>
        </production>
        <production>
            <header>SK</header>
            <prodvalue>12.3</prodvalue>
            <plandiff>1.3</plandiff>
        </production>
        <production>
            <header>MK3</header>
            <prodvalue>11.1</prodvalue>
            <plandiff>0.6</plandiff>
        </production>
        <production>
            <header>BUV</header>
            <prodvalue>11.3</prodvalue>
            <plandiff>0.4</plandiff>
        </production>
        <production>
            <header>ANR</header>
            <prodvalue>8.2</prodvalue>
            <plandiff>2.4</plandiff>
        </production>
      </section>
      <section>
        <header>Ores</header>
        <production>
            <header>Sweden</header>
            <prodvalue>72.6</prodvalue>
            <plandiff>-3.3</plandiff>
        </production>
        <production>
            <header>Norway</header>
            <prodvalue>56.5</prodvalue>
            <plandiff>7.3</plandiff>
        </production>
      </section>
      <section>
        <header>Train</header>
        <production>
            <header>Sweden</header>
            <prodvalue>6</prodvalue>
            <plandiff>-4</plandiff>
        </production>
        <production>
            <header>Norway</header>
            <prodvalue>4</prodvalue>
            <plandiff>-1</plandiff>
        </production>
      </section>
    </production>
    I second this question. There don't seem to be any examples on how to deal with this. Right now, I'm not sure if it's IMPOSSIBLE with ST 2.0, or if I'm just setting up the associations incorrectly.

Similar Threads

  1. Nested Xml with associations?
    By kaine in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 15 Feb 2012, 3:46 AM
  2. [FIXED-583] nested xml / complex xml, cant get associations to work
    By Nostromo in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 19 Nov 2010, 7:39 AM
  3. Replies: 1
    Last Post: 5 May 2009, 8:54 AM
  4. Nested View Objects/Nested Xml collections
    By dwebsubmit in forum Ext 1.x: Help & Discussion
    Replies: 10
    Last Post: 11 Oct 2007, 2:30 PM

Thread Participants: 9

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar