LOAD CUSTOM XML PROBLEMS

Hi,

I,ve been trying to load a custom XML from a data island in the HTML page but it doesn´t works. By the other side if I load it from a file it works well but only in Firefox, not in IE.

I´m working with your sample code: docs.dhtmlx.com/doku.php?id=dhtm … ta_loading

mygrid.parse(xmlTest,“custom_xml”); --> Doesn´t Work

mygrid.load(“data.xml”,“custom_xml”); --> It works only in Firefox, not IE

My data.xml file:


<?xml version="1.0" encoding="UTF-8"?> 15 active 15 active ****************************************************************************************************

My HTML page:


	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
	
	<link rel="STYLESHEET" type="text/css" href="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/dhtmlxgrid.css">
	<link rel="STYLESHEET" type="text/css" href="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">

	<script src="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
	<script src="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/dhtmlxcommon_debug.js"></script>
	<script src="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
	<script src="dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>

<script>

		var mygrid;
		
		function doInitGrid() {
		
			mygrid = new dhtmlXGridObject('mygrid_container');
			
			[b]mygrid._process_custom_xml=function(xml) {[/b]
				this._parsing=true;
				[b]var rows = xml.doXPath("//item");[/b]
                                    [b]//The doXPath line doesn´t work. Only with firefox from a text file.[/b]
				for (var i = 0; i < rows.length; i++) {
					var id = this.getUID();
					this.rowsBuffer[i]={ idd: id, data: rows[i], _parser: this._process_custom_xml_row, _locator: this._get_custom_xml_data };
					this.rowsAr[id]=rows[i];
				}
				
				this.render_dataset();
				this._parsing=false;
			}
        
		[b]mygrid._process_custom_xml_row=function(r, xml){[/b]
        var size = this.xmlLoader.doXPath("./size", xml)[0];
        var mode = this.xmlLoader.doXPath("./mode", xml)[0];
        var strAr = [  
            xml.getAttribute("name"),
            size.firstChild.data,
            mode.firstChild.data,
            mode.getAttribute("online")
        ];
        r._attrs={};
        for (j=0; j < r.childNodes.length; j++) r.childNodes[j]._attrs={};
        this._fillRow(r, strAr);
        return r;
    }

			mygrid.setImagePath("dhtmlxGrid-2.6.1-package/dhtmlxGrid/codebase/imgs/");

			mygrid.setHeader( [ "A" , "B" , "C" , "D" ] );
			mygrid.setColTypes("ro,ro,ro,ro");
			mygrid.setColSorting("str,str,str,str");
			
			mygrid.setInitWidths("150,150,150,*");
			mygrid.setColAlign("left,right,right,right");
			mygrid.init();
 		
 		[b]mygrid.load("data.xml","custom_xml");[/b] WORKS ONLY IN FIREFOX
 		[b]mygrid.parse(xmlTest,"custom_xml");[/b] DOESNT´T WORK


		}

	</script>

</head>
	<div id="mygrid_container" style="width:1000;height:600;"></div>

<?xml version="1.0" encoding="UTF-8"?>


15
active


15
active

</body>
****************************************************************************************************

Any idea? Thanks in advance…

Why is your xml file not started with line <?xml >? May be in this error?

Try to add right after:

mygrid._process_custom_xml=function(xml){

the following sample:

if (!xml.doXPath){ var t = new dtmlXMLLoaderObject(function(){}); if (typeof xml == "string") t.loadXMLString(xml); else { if (xml.responseXML) t.xmlDoc=xml; else t.xmlDoc={}; t.xmlDoc.responseXML=xml; } xml=t; }

Also see the attached working html.
01_calendar_grid.zip (1.67 KB)