Search code examples
phpxmlwriter

php xmlwriter - possible to take a resource/file pointer instead of path?


Instead of doing

$path_out = 'output.xml';

$xw = new XMLWriter();
$xw->openURI($path_out);

Is it possible, using another method or any other way, to do something like:

$path_out = 'output.xml';
$fp = open($path_out, 'w');

$xw = new XMLWriter();
$xw->openURI($fp);

Solution

  • No and this does indeed really suck. The XMLWriter/XMLReader combo are supposed to operate 'streaming' which is awesome but then they can't work with already open streams. This seems like a major oversight.