Index: typo3/classes/class.typo3ajax.php =================================================================== --- typo3/classes/class.typo3ajax.php (revision 4016) +++ typo3/classes/class.typo3ajax.php (working copy) @@ -231,7 +231,15 @@ protected function renderAsXML() { header('Content-type: text/xml; charset='.$this->charset); header('X-JSON: true'); - echo implode('', $this->content); + $xmlString = implode('', $this->content); + // Use SimpleXML utility to check XML validity + if (simplexml_load_string($xmlString)) { + // String is valid XML, return it as is + echo $xmlString; + } + else { + echo t3lib_div::array2xml($this->content); + } }