note 66226 deleted from function.domxml-open-file by sobak
| From: | sobak@php.net | Date: | Tue, 22 Nov 2016 03:42:52 +0000 |
| Subject: | note 66226 deleted from function.domxml-open-file by sobak | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207429@lists.php.net to get a copy of this message | ||
Note Submitter: A-Wing (info at a-wing dot co dot uk)
----
A very useful undocumented feature if you are opening hundreds of xml docs (my script processes
20,000) is DomDocument->free.
This clears the allocated the memory used by the xml file which is not done automatically by just
opening a new file on the same variable.
Example:
<?
$dir="/path/to/xml/files/";
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if(is_file($dir.$file))
{
echo $file . "\\n";
$dom=domxml_open_file($dir.$file);
#...
#You xml processor here
#...
$dom->free();
}
}
closedir($dh);
}
?>