saveDomDocument

Saves the XML document into a file.

Description

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

Parameters (2)

0. $doc (DOMDocument)
The doc.
1. $filename (string)
The filename.

Usage

  1. if ( !function_exists( 'saveDomDocument' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/misc.php'; 
  3.  
  4. // The doc. 
  5. $doc = null; 
  6.  
  7. // The filename. 
  8. $filename = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = saveDomDocument($doc, $filename); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/misc.php  
  1. function saveDomDocument($doc, $filename) { 
  2. $config = $doc->saveXML(); 
  3. $config = preg_replace("/([^\r])\n/", "$1\r\n", $config); 
  4. $fp = fopen($filename, 'w'); 
  5. fwrite($fp, $config); 
  6. fclose($fp);