From 100c7066743adcd670fc20903a13d634cfcc3e08 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 22 May 2013 18:11:41 +0000 Subject: [PATCH] Add an additional condition to check in case the template file is not recognized as XML, and try to parse it --- etemplate/js/et2_core_xml.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/etemplate/js/et2_core_xml.js b/etemplate/js/et2_core_xml.js index c5e98b8def..bf6459eaca 100644 --- a/etemplate/js/et2_core_xml.js +++ b/etemplate/js/et2_core_xml.js @@ -67,6 +67,21 @@ function et2_loadXMLFromURL(_url, _callback, _context) var xmldoc = xmlhttp.responseXML.documentElement; _callback.call(_context, xmldoc); } + // Sometimes it's not recogized as XML - reason unknown + else if (xmlhttp.response) + { + egw().debug("log","File was not recogized as XML, trying to parse text..."); + var response = xmlhttp.response.replace(/^\s+|\s+$/g,''); + // Manually parse from text + var parser = new DOMParser(); + try { + var xmldoc = parser.parseFromString(response, "text/xml"); + egw().debug("log","Parsed OK"); + _callback.call(_context, xmldoc.documentElement); + } catch (e) { + egw().debug("log", "Well, that didn't work"); + } + } } }