xmlReader 读取数据
xmlReader.js:
var _store = new Ext.data.Store({
url:'xmlReader.xml',
reader:new Ext.data.XmlReader({
record:'row',
fields:['name','sex','age','address']
})
});
_store.load();
xmlReader.xml:
<?xml version="1.0" encoding="gbk"?>
<xml-body>
<root>
<results>30</results>
<row>
<name>巴菲特1</name>
<sex>男</sex>
<age>60</age>
<address>美国</address>
</row>
<row>
<name>比尔盖茨2</name>
<sex>男</sex>
<age>50</age>
<address>美国2</address>
</row>
<row>
<name>唐骏3</name>
<sex>男</sex>
<age>50</age>
<address>中国</address>
</row>
</root>
</xml-body>
xmlStore:
xmlStore.js:
var _store = new Ext.data.XmlStore({
url:'xmlStore.xml',
record:'Item',
totalRecords:'@TotalResults',
fields:[
{name:'Author',mapping:'ItemAttributes>Author'},
'Title','Manufacture','ProductGroup','ASIN'
]
});
_store.load();
xmlStore.xml:
<?xml version="1.0" encoding="UTF-8"?>
<xml-body>
<Items>
<request>
<IsValid>True</IsValid>
<ItemSearchRequest>
<Author>Sidney Sheldon</Author>
<SearchIndex>Books</SearchIndex>
</ItemSearchRequest>
</request>
<TotalResults>203</TotalResults>
<Item>
<ASIN>1</ASIN>
<DetailPageURL>
http://www.amazon.com
</DetailPageURL>
<ItemAttributes>
<Author>Sidney Sheldon</Author>
<Manufacture>Warner Books</Manufacture>
<ProductGroup>Book</ProductGroup>
<Title>Master of the Game</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>2</ASIN>
<DetailPageURL>
http://www.amazon.com
</DetailPageURL>
<ItemAttributes>
<Author>Sidney Sheldon</Author>
<Manufacture>Warner Books</Manufacture>
<ProductGroup>Book</ProductGroup>
<Title>Master of the Game</Title>
</ItemAttributes>
</Item>
</Items>
</xml-body>