2011-11-17 84 views
0

我以xml格式從ajax請求獲得響應,但我如何使用sencha touch解析它們? 例如:如何使用sencha touch解析XML?

Ext.Ajax.request(
    { 
     url: "", 
     xmlData: "", 
     method: "POST", 
     callback: function(options, success, response) 
     { 
      //response.responseText is equal to <a><b>value</b></a> 
      if (success) { 
      //Parsing response.responseText ... 
      } 
     } 
}); 

回答

2

所有現代瀏覽器都內置XML解析器 XML Parsing (w3 Schools)

如果要加載的機型商店和爲您服務的結果是XML,那麼你可以使用XML閱讀器:

var store = new Ext.data.Store({ 
    model: 'User', 
    autoLoad:true, 
    proxy: { 
    type: 'ajax', 
    url : 'ajax/user.xml', 
    reader: { 
    type : 'xml', 
    model: 'User', 
    record: 'user' 
    } 
    } 
});