Categories | Question details Back To List | ||
Load XML directly (not as string) Hello, I have some data in XML representation that I would like to load into DHTMLX Tree. Unfortunately, DHTMLX Tree can only load XML in string representation. Hence, I convert the XML to a string like this: var xmlString = (new XMLSerializer()).serializeToString(xmlData); This is slow, but works perfectly in Firefox. However, it does not work in IE (latest version). Is there any way to pass the XML directly to DHTMLX Tree, without having to convert it to a string first? Thank you! Steffen Answer posted by Support on Dec 19, 2007 08:31 there is no native API, but can be done in next way if your object is instance of XMLHTTPRequest you can init tree as var temp=new dtmlXMLLoaderObject(); temp.xmlDoc=xml_obj; tree._parseXMLTree(tree,null,null,null,null,temp); If its just an XML document ( only starting from dhtmlxtree 1.6 ) var top= <<top node of xml, fetched from your object>>; var pointer=new xmlPointer(top); tree._parse(pointer) tree._p=pointer; Also, just for info , it possible to serialize data to string in IE as well var xmlString = xmlData.documentElement.xml; Answer posted by Stefan Mueller on Dec 19, 2007 09:39 Hello, Thanks for your quick reply - I greatly appreciate it. I am about to try the second solution you proposed, but don't know how to find the top node: var top = <<top node of xml, fetched from your object>>; I tried var top = $(data).find("tree"); using jQuery, but that didn't work. I use the regular XML syntax, starting with <tree>. Thanks in advance, Steffen Answer posted by Steffen on Dec 20, 2007 01:03 Actually, var top = data.documentElement; did the trick. Is this the correct way of finding the top node? Thanks, Steffen Answer posted by Support on Dec 20, 2007 02:18 >>did the trick. Is this the correct way of finding the top node? This is definitely correct for IE, not sure that it correct for all versions of FF You can use xml.getElementsByTagName("tree")[0] |