extjs如何读内存中的xml数据

代码如下:

var record = new Ext.data.Record.create(['name', 'number']);
var reader = new Ext.data.XmlReader({
record: 'item'
}, record);
var connection = new Ext.data.Connection({timeout: 10000});
connection.request({
url: 'generatedata.jsp',
callback: tidydata,
method: 'post'
});

    function tidydata(options, success, response)
    {
        var xmlString = response.responseText;
        var proxy = new Ext.data.MemoryProxy(xmlString);
        //proxy.load(null, reader, doafterload);
        proxy.doRequest(null, null, null, reader, doafterload );
        function doafterload(result, a, b, c){
            var records = result.records;
            var totalRecords = result.totalRecords;
        }           
    }

大家且不要管我为何这样写代码,听我说问题:

进入到tidydata函数时通过ff看到xmlString是这样的:
<?xml version="1.0" encoding="ISO-8859-1"?>


name 5
number 5

可是当进入到doafterload函数中后看到result.records是一个空数组,显然是没有加载进来,不知道怎么回事

另外我是用的Ext3,不知道如何解决啊????

[quote]proxy.doRequest(null, null, null, reader, doafterload );
function doafterload(result, a, b, c){
var records = result.records;
var totalRecords = result.totalRecords;
} [/quote]

[quote]到doafterload函数中后看到result.records是一个空数组[/quote]

API
doRequest( String action, Ext.data.Record/Ext.data.Record[] rs, Object params, Ext.data.DataReader reader, Function callback, Object scope, Object arg )

url: 'generatedata.jsp', //你的数据是从服务器获得,为什么还要通过读取内存数据的方式呢?

读取xml数据extjs有专门的类 Ext.data.XmlReader

下面是示例
[url]http://www.extjs.com/deploy/dev/examples/grid/xml-grid.html[/url]

[code="js"]
/*!

  • Ext JS Library 3.0+
  • Copyright(c) 2006-2009 Ext JS, LLC
  • licensing@extjs.com
  • http://www.extjs.com/license
    */
    Ext.onReady(function(){

    // create the Data Store
    var store = new Ext.data.Store({
    // load using HTTP
    url: 'sheldon.xml',

    // the return will be XML, so lets set up a reader
    reader: new Ext.data.XmlReader({
           // records will have an "Item" tag
           record: 'Item',
           id: 'ASIN',
           totalRecords: '@total'
       }, [
           // 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'
       ])
    

    });

    // create the grid
    var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [
    {header: "Author", width: 120, dataIndex: 'Author', sortable: true},
    {header: "Title", width: 180, dataIndex: 'Title', sortable: true},
    {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
    {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
    ],
    renderTo:'example-grid',
    width:540,
    height:200
    });

    store.load();
    });

[/code]