سؤال

I am trying to load XML content on my dhtmlxTree object but a have following errors :

Error type: DataStructure Description: XML refers to not existing parent

On the formus they say me that it is problem of rootId

so, this is my code :

..........
naccordion = new dhtmlXAccordion("accordiondiv", "dhx_skyblue");
navTree = naccordion.cells("actree").attachTree();

var xmlDoc;

    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET","toc.xml",false);
    xmlhttp.send();

    xmlDoc=xmlhttp.responseXML;

    console.log(xmlDoc);

    //navTree.loadXML("toc.xml", function () {

    navTree.loadXMLString(xmlDoc, function () {
.......................
}

I know that I can do it if I use dhtmlXTreeObject:

var mytree = new dhtmlXTreeObject("my_tree_here","100%","100%",0);

but in my case it is created by attachTree

my XML file have this structure :

<?xml version='1.0' encoding='utf-8' ?>
<tree id="root">
<item id="A1">some text</item>
<item id="A2">some text</item>
<item id="A3">some text</item>
</tree>
هل كانت مفيدة؟

المحلول

If you need to use root id as "root" - you need to set this ID in a tree init:

var mytree = new dhtmlXTreeObject("my_tree_here","100%","100%","root");

or use

layout.cells("a").attachTree("root")
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top