2

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?

Harry
  • 678
  • 10
  • 26

1 Answers1

3
  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);
    }
});
Alexander.Berg
  • 2,225
  • 1
  • 17
  • 18
  • With Extjs 3.4 and IE7 my response.responseXML always comes out empty. It would work in later versions of IE and other browsers of course. Odd thing was the response.responseText had the xml string. So finally I used window.DOMParser to load it into an xmlDoc(if IE used loadXML). – dwp4ge Jan 10 '14 at 21:53