Gregoire
Gregoire

Reputation: 198

How can I parse XML with sencha touch?

I obtain response from ajax request in xml format, but how can I parse them using sencha touch? For example :

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

Upvotes: 0

Views: 1219

Answers (1)

stan229
stan229

Reputation: 2607

All modern browsers have a built in XML Parser XML Parsing (w3 Schools)

If you are trying to load a store with models and your service result is XML then you can use the xml reader:

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

Upvotes: 2

Related Questions