Harry
Harry

Reputation: 678

How to read local XML file in ExtJS?

I use ExtJS 4.2. What is the easiest way to read local XML file? I understand that it's possible to use store and model, but I prefer other way. Is it possible to use Ext.Ajax.Request?

For example, this is my XML file content:

<LocaleText>
  <Item>
    <CTRO_CONTROLID>lblLoginTitle</CTRO_CONTROLID>
    <CTRO_CONTROLTYPE>label</CTRO_CONTROLTYPE>
  </Item>
    <Item>
    <CTRO_CONTROLID>cboLoginLanguage</CTRO_CONTROLID>
    <CTRO_CONTROLTYPE>combobox</CTRO_CONTROLTYPE>
  </Item>
</LocaleText>

How can I get the data of each Item node?

Upvotes: 2

Views: 3954

Answers (1)

Alexander.Berg
Alexander.Berg

Reputation: 2245

  1. You can use the response.responseXML in the Ext.Ajax.request for getting the xml type response.
  2. and you can use the Ext.DomQuery class for getting data out from an xml

Example:

Ext.Ajax.request({           
    url: '/your/url/here/test.xml',            
    success: function (response, options) {
        var object = response.responseXML;
        var test = Ext.DomQuery.select('Item', object);
        console.log('test', test);
    }
});

Upvotes: 3

Related Questions