Showing LoadXML errors

Hi,

We are using DhtmlXTree 2.5 Pro and are creating XML for the tree.LoadXML() using an asp.net 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 dhtmlx.com/docs/products/doc … 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;
                errorXmlDoc.loadXML(data[0].responseText);
            }

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

            alert(message);
        }
        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:

dhtmlxError.catchError("ALL",dhtmlxtreeErrorReport);

… as it was catching and handling all window errors.

Hi
Please, provide us completed demo on support@dhtmlx.com with link to this topic
docs.dhtmlx.com/doku.php?id=othe … leted_demo
We will inspect it

Oh, have reload the page. Ok :slight_smile: