DHTMLX Docs & Samples Explorer

Loading from XML

There is an opportunity to load data from xml file, string or island:


Reload from XML string
Reload from XML island
Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>        
<script  src="../../codebase/dhtmlxgridcell.js"></script>    
<script  src="../common/data.js"></script>    
 
 
 
    <div id="gridbox" style="width:400px; height:270px; background-color:white;"></div>
<br>
<a href="javascript:void(0)" onClick="mygrid.clearAll();mygrid.parse(document.getElementById('str_xml').value);">Reload from XML string</a><br/>
<a href="javascript:void(0)" onClick="mygrid.clearAll();mygrid.parse(document.getElementById('isl_xml'));">Reload from XML island</a><br/>
<textarea id="str_xml" style="display:none;"><rows>
   <row id="1">
  <cell>0</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="2">
  <cell>1</cell>
 <cell>loaded from xml string</cell>
   </row>
   <row id="3" selected="1">
  <cell>2</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="4">
  <cell>3</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="5">
  <cell>4</cell>
 <cell>loaded from xml string</cell>
   </row>
   <row id="6">
  <cell>5</cell>
   <cell>loaded from xml string</cell>
   </row>
   <row id="7">
  <cell>6</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="8">
  <cell>7</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="9">
  <cell>8</cell>
  <cell>loaded from xml string</cell>
   </row>
   <row id="10">
  <cell>9</cell>
   <cell>loaded from xml string</cell>
   </row>
   <row id="11">
  <cell>10</cell>
   <cell>loaded from xml string</cell>
   </row>
</rows></textarea>
<xml id="isl_xml" style="display:none;"><rows>
   <row id="1">
  <cell>0</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="2">
  <cell>1</cell>
 <cell>loaded from xml island</cell>
   </row>
   <row id="3" selected="1">
  <cell>2</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="4">
  <cell>3</cell>
 <cell>loaded from xml island</cell>
   </row>
   <row id="5">
  <cell>4</cell>
 <cell>loaded from xml island</cell>
   </row>
   <row id="6">
  <cell>5</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="7">
  <cell>6</cell>
 <cell>loaded from xml island</cell>
   </row>
   <row id="8">
  <cell>7</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="9">
  <cell>8</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="10">
  <cell>9</cell>
  <cell>loaded from xml island</cell>
   </row>
   <row id="11">
  <cell>10</cell>
  <cell>loaded from xml island</cell>
   </row>
</rows></xml>
 
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Column A,Column B");
mygrid.setInitWidths("100,*");
mygrid.setColAlign("right,right");
mygrid.setColTypes("ed,ed");
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.load("php/xml.php", "xml");
</script>