这是我的源代码:
dom = new \DOMDocument("1.0", "UTF-8");
$translationXml = $dom->createElement('translation');
$translationXml->setAttribute('lang', $language->url_key);
$translationXml->setAttribute('website', $websiteId);
$translationXml->appendChild($dom->createCDATASection('<test>'));
$dom->appendChild($translationXml);
$dom->formatOutput = true;
header('Content-type: text/xml');
echo $dom->saveXML();
以下是输出:
<translation lang="en" website="4">
<![CDATA[ <test> ]]>
</translation>
如何删除这些空格?