View Full Version : XmlStore: Get special field of xml

7 Apr 2010, 10:36 PM

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">
<Author>Sidney Sheldon</Author>
<Author>Sidney Sheldon</Author>
<Manufacturer>Warner Books</Manufacturer>
<Title>Master of the Game</Title>

My question is: How can I get/store the value of <TotalPages>?

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

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?

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);

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