1. #1
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default Please help

    Please help


    How do i read this xml i tried using the foll but it doesnt work

    Ext.regModel('HitrateRegel',{
    fields:[


    { name: 'title', type: 'string', mapping:'@title'},
    { name: 'catId', type: 'string', mapping:'@catId'}
    ]
    });

    Nested XML

    Code:
    <?xml version="1.0" encoding="ISO8859-1" ?>
    <categories>
    <category>
    <name catId="106" title="Belay Devices"/>
    <name catId="108" title="Belay Devices Inside"/>
    </category>
    </categories>

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    You have to provide more information about the code you use to read your xml.
    I can't understand how you are trying to read it because I only see you declared a model and nothing else.
    If you can post the full code or part of it.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default Code

    Code


    Hello Here is the code

    Code:
    Ext.regModel('HitrateRegel',{
    fields:[
    { name: 'title', type: 'string', mapping:'@title'},
    { name: 'catId', type: 'string', mapping:'@catId'}
    ]
    });
    
    var HitrateStore = new Ext.data.Store({
    model: 'HitrateRegel',
    proxy: {
    type: 'ajax',
    url: 'data.xml',
    reader: {
    type: 'xml',
    record:'category'
    }
    },
    listeners: {
    load: function(store, records, success) {
    console.log(store);
    console.log(records);
    console.log(success);
    }
    }
    });
    
    testtpl = '<div class="contact"><table><tr><td><strong>{title}</strong><br>{catId}</td></tr></table></div>';
    
    topics = new Ext.List({
    tpl:'<tpl for=".">'+ testtpl +'</tpl>',
    xtype: 'list',
    cls: 'demo-list',
    itemSelector: 'div.contact',
    iconCls: 'topicIcon',
    title:'Topics',
    store: HitrateStore,
    listeners: {
    beforeactivate: function(c)
    {
    HitrateStore.load();
    }
    }
    });
    Here is the XML

    Code:
    <?xml version="1.0" encoding="ISO8859-1" ?>
    <categories>
    <category>
    <name catId="106" title="Belay Devices"/>
    <name catId="108" title="Belay Devices Inside"/>
    </category>
    </categories>

  4. #4
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default


    Hello Where you able to check the code ?
    Quote Originally Posted by andreacammarata View Post
    You have to provide more information about the code you use to read your xml.
    I can't understand how you are trying to read it because I only see you declared a model and nothing else.
    If you can post the full code or part of it.

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    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


    In your reader, set the root: "categories"

    Code:
    ...
    reader: {
        type: 'xml',
        root: "categories",
        record:'category'
    }
    ...
    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.

  6. #6
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default


    I changed it but its not reading it, is the following mapping ok ? Also is root: "categories" correct or root: 'categories', i tried with both but its not working

    { name: 'title', type: 'string', mapping:'@title'},
    { name: 'catId', type: 'string', mapping:'@catId'}


    Quote Originally Posted by mitchellsimoens View Post
    In your reader, set the root: "categories"

    Code:
    ...
    reader: {
        type: 'xml',
        root: "categories",
        record:'category'
    }
    ...

  7. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,620
    Vote Rating
    817
    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


    double-quotes or single-quotes don't matter, I just prefer it personally. Most prefer single-quotes.

    try your fields without the mapping field. Does it work then?

    Code:
    { name: 'title', type: 'string'},
    { name: 'catId', type: 'string'}
    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.

  8. #8
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default


    No tried with following, doesnt work

    Code:
    Ext.regModel('HitrateRegel',{
    fields:[
    { name: 'title', type: 'string'},
    { name: 'catId', type: 'string'}
    ]
    });
    
    var HitrateStore = new Ext.data.Store({
    model: 'HitrateRegel',
    proxy: {
    type: 'ajax',
    url: 'data.xml',
    reader: {
    type: 'xml',
    root: "categories",
    record:'category'
    }
    Quote Originally Posted by mitchellsimoens View Post
    double-quotes or single-quotes don't matter, I just prefer it personally. Most prefer single-quotes.

    try your fields without the mapping field. Does it work then?

    Code:
    { name: 'title', type: 'string'},
    { name: 'catId', type: 'string'}

  9. #9
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    What's the error you get if you include sencha-touch-debug.js instead sencha-touch.js?
    Did you get a loading error like "Result of expression 'records' [undefined] is not an object" or what else?
    Anyway check even your list configuration:
    You set a tpl config param in the code you posted but you have to use itemTpl.

    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  10. #10
    Ext User
    Join Date
    Jan 2011
    Posts
    33
    Vote Rating
    0
    nileshbhd5 is on a distinguished road

      0  

    Default


    This is the error i see when i use

    sencha-touch-debug.js

    This is the error i see when i use sencha-touch-debug.js

    Code:
    Uncaught Error: Ext.List: itemTpl is a required configuration.
    /sencha-touch-debug.js:23116Uncaught Error: Ext.List: itemTpl is a required configuration.
    /search.js:2Uncaught TypeError: undefined is not a function
    /sencha-touch-debug.js:23116Uncaught Error: Ext.List: itemTpl is a required configuration.

    Quote Originally Posted by andreacammarata View Post
    What's the error you get if you include sencha-touch-debug.js instead sencha-touch.js?
    Did you get a loading error like "Result of expression 'records' [undefined] is not an object" or what else?
    Anyway check even your list configuration:
    You set a tpl config param in the code you posted but you have to use itemTpl.