将XML文档保存到文件中

原型

saveDomDocument( DOMDocument $doc, string $filename )

参数

$doc (DOMDocument) (Required)

$filename (string) (Required)

源文件

路径:wp-admin/includes/misc.php

<?php
...
function saveDomDocument($doc, $filename) {
	$config = $doc->saveXML();
	$config = preg_replace("/([^r])n/", "$1rn", $config);
	$fp = fopen($filename, 'w');
	fwrite($fp, $config);
	fclose($fp);
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/savedomdocument/