Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by raju on Dec 17, 2008 00:11
open dhtmlx forum
Regarding error in loading the xml in jsp page

loadXML not working

When I using loadXML function I got two alert messages

1) Error type:LoadXML
Descriptin :Incorrect XML

2) Error type:DataStructure
Descriptin :XML refers to not existing parent

I have write data to file while calling an ajax function (using java) and then loading this file like this

function get_method()
{

createXMLHttpReq();
var url = "/treestructure/tree.do?method=getTreeData";
req.open("GET",url,true);
req.onreadystatechange = load_districts;
req.send(null);

} // end of get_districts()

function load_districts()
{

if(req.readyState == 4)
{

if(req.status == 200)
{
alert('this is get_district function()');
//var xmlDoc = req.responseXML;
tree2=new dhtmlXTreeObject("treeboxbox_tree2","100%","100%",0);
            tree2.setImagePath("./codebase/imgs/csh_bluebooks/");
            tree2.enableCheckBoxes(1);
            tree2.enableThreeStateCheckboxes(true);
            tree2.loadXML(req.responseXML);
            //tree2.setXMLAutoLoading(req.responseXML);
                        
}// end of if(xmlRequest.status==200)

} // end of if(xmlRequest.readyState==4)

} // end of load_districts()
    
The file is like this


<?xml version='1.0' encoding='iso-8859-1'?>
<tree id="0">
        <item text="Magazines" id="magazines" im0="folderClosed.gif" im1="folderOpen.gif" im2="folderClosed.gif">
        <item text="Sport" id="mag_sp" im0="folderClosed.gif" im1="folderOpen.gif" im2="folderClosed.gif"></item>
    </item>
</tree>


pls help me out.

Advance Thanx
Answer posted by Support on Dec 17, 2008 03:30
You are need not load XML through custom code, the component already has all necessary to load data correctly, it can be done as

  tree2.loadXML( "/treestructure/tree.do?method=getTreeData");

In common case, the same error occurs when incoming XML stream contains some syntax errors. 
http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Common_Problems_in_Grid.html#grid_art_comprob