简单的问题,如何用 DOMDocument 做到这一点?
<backend>
<type value="File" />
<cache_dir>
<zf:const zf:name="APPLICATION_PATH"/>.cache</cache_dir>
</backend>
没有以下结果:
<backend>
<type value="File"/>
<cache_dir><zf:const zf:name="APPLICATION_PATH"/>.cache</cache_dir>
</backend>
这是我所做的:
$backendNode = $paramsNode->appendChild($cnfXml->createElement('backend'));
$backendNode->appendChild($cnfXml->createElement('type'))->setAttribute('value', 'File');
$pathnode = $backendNode->appendChild($cnfXml->createElement('cache_dir'));
$pathnode->appendChild($cnfXml->createElement('zf:const'))->setAttribute('zf:name', 'APPLICATION_PATH');
$pathnode->nodeValue .= '.cache';