Results 1 to 5 of 5

Thread: XmlStore: Get special field of xml

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Location
    Munich (Bavaria/Germany)
    Posts
    291

    Default XmlStore: Get special field of xml

    Hi,

    in the documentation is an example how to use the XmlStore:

    Code:
    
    
    Code:
    var store = new Ext.data.XmlStore({
        // store configs
        autoDestroy: true,
        storeId: 'myStore',
        url: 'sheldon.xml', // automatically configures a HttpProxy
        // reader configs
        record: 'Item', // records will have an "Item" tag
        idPath: 'ASIN',
        totalRecords: '@TotalResults'
        fields: [
            // set up the fields mapping into the xml doc
            // The first needs mapping, the others are very basic
            {name: 'Author', mapping: 'ItemAttributes > Author'},
            'Title', 'Manufacturer', 'ProductGroup'
        ]
    });
    


    with this data:

    Code:
    
    
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2009-05-15">
        <Items>
            <Request>
                <IsValid>True</IsValid>
                <ItemSearchRequest>
                    <Author>Sidney Sheldon</Author>
                    <SearchIndex>Books</SearchIndex>
                </ItemSearchRequest>
            </Request>
            <TotalResults>203</TotalResults>
            <TotalPages>21</TotalPages>
            <Item>
                <ASIN>0446355453</ASIN>
                <DetailPageURL>
                    http://www.amazon.com/
                </DetailPageURL>
                <ItemAttributes>
                    <Author>Sidney Sheldon</Author>
                    <Manufacturer>Warner Books</Manufacturer>
                    <ProductGroup>Book</ProductGroup>
                    <Title>Master of the Game</Title>
                </ItemAttributes>
            </Item>
        </Items>
    </ItemSearchResponse>


    My question is: How can I get/store the value of <TotalPages>?
    Checkout Apollo, an ExtJS4-based Apache Cassandra client: http://www.codefreun.de/en/apollo-en

  2. #2
    Sencha User
    Join Date
    Dec 2008
    Location
    Munich (Bavaria/Germany)
    Posts
    291

    Default

    Is it possible to get the value of <TotalPages>?
    Checkout Apollo, an ExtJS4-based Apache Cassandra client: http://www.codefreun.de/en/apollo-en

  3. #3
    Sencha User
    Join Date
    Dec 2008
    Location
    Munich (Bavaria/Germany)
    Posts
    291

    Default

    I really dont know how to get the value of <TotalPages> into my records. Are there any special notations I could try?
    Checkout Apollo, an ExtJS4-based Apache Cassandra client: http://www.codefreun.de/en/apollo-en

  4. #4
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    You could probably access it via store.reader.xmlData using DomQuery.selectNumber.

    EDIT: Untested:

    Code:
     
    Ext.DomQuery.selectNumber(store.reader.xmlData, 'TotalPages', 0);

  5. #5
    Sencha User
    Join Date
    Dec 2008
    Location
    Munich (Bavaria/Germany)
    Posts
    291

    Default

    Many thanks ... you just twisted the parameters!
    Checkout Apollo, an ExtJS4-based Apache Cassandra client: http://www.codefreun.de/en/apollo-en

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •