如何使用sencha touch解析XML?

时间:2011-11-17 16:30:19

标签: xml xml-parsing sencha-touch

我以xml格式获取ajax请求的响应,但是如何使用sencha touch解析它们? 例如:

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

1 个答案:

答案 0 :(得分:2)

所有现代浏览器都有内置的XML Parser 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'
   }
  }
});