saveDomDocument() WordPress Function

The saveDomDocument() function is used to save a DOM document to a WordPress database. This function can be used to save any DOM document, including an HTML document, XML document, or XHTML document.

saveDomDocument( DOMDocument $doc, string $filename ) #

Saves the XML document into a file.


Parameters

$doc

(DOMDocument)(Required)

$filename

(string)(Required)


Top ↑

Source

File: wp-admin/includes/misc.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.