1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6
    Vote Rating
    48
    Malte123 is infamous around these parts Malte123 is infamous around these parts

      -1  

    Default Answered: XML Store via ajax-proxy pre-selecting

    Answered: XML Store via ajax-proxy pre-selecting


    Hi all :-)
    this is my first post - I've done a half a year successful with extjs but now I need help:

    I want to pre select a part of an XML like this:

    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <game version="0.8">
    <team name="green">
            <figure><name id="donaldDuck">Donald Duck</name><set>Disney</set></figure>
            <figure><name id="mickeyMouse">Mickey Mouse</name><set>Disney</set></figure>
    </team>
    <team name="red">
            <figure><name id="tick">Tick</name><set>children</set></figure>
            <figure><name id="trick">Trick</name><set>children</set></figure>
    </team>
    </game>
    If I want to load name="green" and name="red" into different Stores - how can I do this?

    I tried a lot - and I am confused a little bit:
    (here I use a Model with its own Ajax-Proxy-Reader)

    PHP Code:
    reader: {
                    
    type'xml',
               
    //    record: 'team/@name=[red]',
                     
    record'> *',
              
    //     root: 'figure',
             //      root: 'game',
                     
    root'team',
            
    //       root: 'team/@name=[red]
                    
    idProperty'team/@name/figure/name/@id'
                

    Can someone tell me the right way to filter this while loading into store - I do not want to filter the stores because than I have a lot of Stores with same content (here we have only small sample data)

    I only need <figure> and deeper - but I have to manage only <team name="red" OR "green"> is in the store later - WITHOUT store.filter()

    If there is no solution please give me a successful way to look for like converting xml to json and than manage this with a json ??! Or something successful tested :-)

  2. PHP Code:
    reader: {
           
    type'xml'
           
    ,root'team[@name=red]' // correct way to select
           
    ,record'figure'
           
    ,idProperty'name/@id'

    thanks to mitchellsimoens for unconfusing me ;-)

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3461
    Vote Rating
    827
    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


    All you should have to do is have different root properties using the attribute selector also.
    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
    Dec 2013
    Posts
    84
    Answers
    6
    Vote Rating
    48
    Malte123 is infamous around these parts Malte123 is infamous around these parts

      -1  

    Default


    root: 'team/@name=[red]'


    should work ?
    (maybe I did a different mistake - please correct me if this is a wrong way to use syntax for selectors in targeting name="red")

    thanks for the response - I did it now manualy by using native JS with XPath..
    It would be nice to know how to do this.
    I didn't find a red path to work with xml - maybe someone with a lot experience can write a doc - in professional work it is needed to work with xml for customers. (I know JSON is to golden way)
    If there were an XML-FAQ it would help a lot not to get confused and make mistakes like me maybe.

  5. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    84
    Answers
    6
    Vote Rating
    48
    Malte123 is infamous around these parts Malte123 is infamous around these parts

      -1  

    Default


    PHP Code:
    reader: {
           
    type'xml'
           
    ,root'team[@name=red]' // correct way to select
           
    ,record'figure'
           
    ,idProperty'name/@id'

    thanks to mitchellsimoens for unconfusing me ;-)

Thread Participants: 1

Tags for this Thread