saveDomDocument()WP 2.8.0

Saves the XML document into a file.

No Hooks.

Return

null. Nothing (null).

Usage

saveDomDocument( $doc, $filename );
$doc(DOMDocument) (required)
-
$filename(string) (required)
-

Changelog

Since 2.8.0 Introduced.

saveDomDocument() code WP 6.6.2

function saveDomDocument( $doc, $filename ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$config = $doc->saveXML();
	$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );

	$fp = fopen( $filename, 'w' );
	fwrite( $fp, $config );
	fclose( $fp );
}