two grids from one xml response

I have an xml file that has two rowsets, each of them contains data to display a grid:

<?xml version="1.0" encoding="utf-8"?> <Rowsets> <Rowset id="1"> <Columns> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="ID" Description="Id"/> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="DATE" Description="Date"/> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="TIME" Description="Time"/> </Columns> <Row> <ID>685</ID> <DATE>2014-09-11</DATE> <TIME>11:10</TIME> </Row> <Row> <ID>686</ID> <DATE>2014-09-11</DATE> <TIME>12:34</TIME> </Row> </Rowset> <Rowset id="2"> <Columns> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="ID" Description="Id"/> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="MIN" Description="Minimum"/> <Column align="center" format="" hidden="false" sort="str" type="ro" width="80" id="MAX" Description="Maximum"/> </Columns> <Row> <ID>688</ID> <MIN>11.48</MIN> <MAX>17.23</MAX> </Row> <Row> <ID>689</ID> <MIN>12.03</MIN> <MAX>18.67</MAX> </Row> </Rowset> </Rowsets>

To be able to display output of the first Rowset as a grid I load data using Ajax, then when I get a response I take a part of it with

var firstRowset = $(result).find('Rowset:eq(0)');

And then I have a problem. No matter which function I use to load xml for grid it goes into error:

testGrid.loadXMLString(firstRowset); /* Error: Unable to get property 'replace' of undefined or null reference] */ testGrid.parse(firstRowset); /* Error: Object doesn't support property or method 'getElementsByTagName' */ testGrid1.loadXML(firstRowset); /* Error: Object doesn't support property or method 'indexOf' */ testGrid1.load(firstRowset); /* Error: Object doesn't support property or method 'indexOf' */

Do I miss something important? Or maybe there is a better approach? Or is it not possible to work with such a file?

Any help will be very appreciated!

Please, refer to the supported xml format of data in dhtmlxgrid:
docs.dhtmlx.com/grid__data_forma … #xmlformat

Thanks for your reply!

Finally I found why it doesn’t work and it’s not because of xml format, you can set your own format for the grid with following lines of code:

testGrid = new dhtmlXGridObject('testGridContainer'); testGrid.setImagePath(".../dhtmlxGrid/codebase/imgs/"); testGrid.setSkin("xp"); testGrid.xml.top="rows"; testGrid.xml.row="./row"; testGrid.xml.cell="./*"; testGrid.init();
The reason why it didn’t work was in a different place. Parse function doesn’t work with jQuery $.ajax or $.get response, but working with XMLHttpRequest response.

Not working examples:

$.get('http://example.xml', function(response) { textGrid.parse(response); });

$.ajax({ type: "GET", url: 'http://example.xml', dataType: "xml", success: function(result){ textGrid.parse(result); } });
Working example:

var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { testGrid.parse(xhr.responseXML); } } xhr.open('GET', 'http://example.xml', true); xhr.send(null);