1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    udhayakumark is on a distinguished road

      0  

    Default Answered: Read Xml data and bind into the list in sencha touch 2

    Answered: Read Xml data and bind into the list in sencha touch 2


    Hi guys,
    This is my first sencha project mobile apps.
    I want read the xml from url and show it on list view in sencha touch2.
    very urgent friends....
    is it possible?

    Xml format will be like this,
    <stations>

    <station id="48">
    <name>xxx96</name>
    <city>mmmm</city>
    <state>ffff</state>
    <latitude>25.94589</latitude>
    <longitude>-80.203683</longitude>





    </station>


    <station id="50">
    <name>abc</name>
    <city>yyy</city>
    <state>xxx</state>
    <latitude>25.94589</latitude>
    <longitude>-80.203683</longitude>
    </stations>




  2. With this XML (based on yours but with a closing </station>):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <stations>
        <station id="48">
            <name>xxx96</name>
            <city>mmmm</city>
            <state>ffff</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
        <station id="50">
            <name>abc</name>
            <city>yyy</city>
            <state>xxx</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
    </stations>
    You can use a store and model like:

    Code:
    Ext.define('MyApp.model.Station', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                { name : 'id', mapping : '@id' },
                'name',
                'city',
                'state',
                'latitude',
                'longitude'
            ]
        }
    });
    
    Ext.define('MyApp.store.Stations', {
        extend : 'Ext.data.Store',
    
        requires : 'MyApp.model.Station',
    
        config : {
            model : 'MyApp.model.Station',
            proxy : {
                type   : 'ajax',
                url    : 'data/xml.xml',
                reader : {
                    type         : 'xml',
                    rootProperty : 'stations',
                    record       : 'station'
                }
            }
        }
    });

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,790
    Answers
    3465
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    With this XML (based on yours but with a closing </station>):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <stations>
        <station id="48">
            <name>xxx96</name>
            <city>mmmm</city>
            <state>ffff</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
        <station id="50">
            <name>abc</name>
            <city>yyy</city>
            <state>xxx</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
    </stations>
    You can use a store and model like:

    Code:
    Ext.define('MyApp.model.Station', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                { name : 'id', mapping : '@id' },
                'name',
                'city',
                'state',
                'latitude',
                'longitude'
            ]
        }
    });
    
    Ext.define('MyApp.store.Stations', {
        extend : 'Ext.data.Store',
    
        requires : 'MyApp.model.Station',
    
        config : {
            model : 'MyApp.model.Station',
            proxy : {
                type   : 'ajax',
                url    : 'data/xml.xml',
                reader : {
                    type         : 'xml',
                    rootProperty : 'stations',
                    record       : 'station'
                }
            }
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    3
    Vote Rating
    0
    udhayakumark is on a distinguished road

      0  

    Default Thanks mitchell

    Thanks mitchell


    works fine.. Thanks Lot

  5. #4
    Sencha User
    Join Date
    Mar 2014
    Posts
    98
    Answers
    5
    Vote Rating
    -4
    franva is infamous around these parts franva is infamous around these parts

      0  

    Default Reply to you

    Reply to you


    Quote Originally Posted by mitchellsimoens View Post
    With this XML (based on yours but with a closing </station>):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <stations>
        <station id="48">
            <name>xxx96</name>
            <city>mmmm</city>
            <state>ffff</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
        <station id="50">
            <name>abc</name>
            <city>yyy</city>
            <state>xxx</state>
            <latitude>25.94589</latitude>
            <longitude>-80.203683</longitude>
        </station>
    </stations>
    You can use a store and model like:

    Code:
    Ext.define('MyApp.model.Station', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                { name : 'id', mapping : '@id' },
                'name',
                'city',
                'state',
                'latitude',
                'longitude'
            ]
        }
    });
    
    Ext.define('MyApp.store.Stations', {
        extend : 'Ext.data.Store',
    
        requires : 'MyApp.model.Station',
    
        config : {
            model : 'MyApp.model.Station',
            proxy : {
                type   : 'ajax',
                url    : 'data/xml.xml',
                reader : {
                    type         : 'xml',
                    rootProperty : 'stations',
                    record       : 'station'
                }
            }
        }
    });
    Hi mitchellsimoens,

    Could you please explain the differences between using Ext.define()(found in my people's code) and Ext.create()(found in SenCha Document) for creating store?
    Also, could you please explain what does the record: 'station' do?

    Best regards,



Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi