public function save($dom,
$file,
$options = array
()) { $close = true;
if (is_resource($file)) { $stream =
$file;
$close = false;
} else { $stream =
fopen($file, 'wb'
);
} $options =
array_merge($this->defaultOptions,
$options);
$rules =
new OutputRules($stream,
$options);
$trav =
new Traverser($dom,
$stream,
$rules,
$options);
$trav->
walk();
/*
* release the traverser to avoid cyclic references and allow PHP to free memory without waiting for gc_collect_cycles
*/
$rules->
unsetTraverser();
if ($close) { fclose($stream);
} }