Showing LoadXML errors


We are using DhtmlXTree 2.5 Pro and are creating XML for the tree.LoadXML() using an page.

We are handling tree load errors using dhtmlxError.catchError();

Sometimes the aspx xml page gets an exception and we would like to pass details of the error back in the xml, for catchError() to handle.

I have looked at the xml schema at … index.html but can’t see any way of returning error information.

Can you tell me if this is possible?

Not to worry. I have figured it out.

If anyone else want to know…

Return xml something like:

"<?xml version=\"1.0\" encoding=\"utf-8\" ?><error><status>0</status><message>An error has occurred: An error</message></error>"

Then for the JS:

dhtmlxError.catchError(""LOADXML"", treeErrorHandler);

function treeErrorHandler(type, name, data) {

    if (data != undefined) {
        try {
            var errorXmlDoc

            if (window.DOMParser) {
                var parser = new DOMParser();
                errorXmlDoc = parser.parseFromString(data[0].responseText, "text/xml");
            else // Internet Explorer
                errorXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                errorXmlDoc.async = this.async;

            var message = errorXmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue;

        catch (err) {

            alert("Error loading tree xml");

p.s. I also had to comment out the following line at the bottom of dhtmlXTree_er.js:


… as it was catching and handling all window errors.

Please, provide us completed demo on with link to this topic … leted_demo
We will inspect it

Oh, have reload the page. Ok :slight_smile: