PDA

View Full Version : XmlStore: Get special field of xml



defcon1
7 Apr 2010, 10:36 PM
Hi,

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



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:



<?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>?

defcon1
15 Apr 2010, 12:55 AM
Is it possible to get the value of <TotalPages>?

defcon1
22 Apr 2010, 7:28 AM
I really donīt know how to get the value of <TotalPages> into my records. Are there any special notations I could try?

fay
22 Apr 2010, 8:23 AM
You could probably access it via store.reader.xmlData (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.XmlReader&member=xmlData) using DomQuery.selectNumber (http://www.extjs.com/deploy/dev/docs/?class=Ext.DomQuery&member=selectNumber).

EDIT: Untested:



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

defcon1
26 Apr 2010, 1:19 AM
Many thanks ... you just twisted the parameters! ;)