trav Posted March 3, 2011 Share Posted March 3, 2011 Hi All, It has been a while since I posted, but I am hoping someone can help me out as I have definitely reached the end of my knowledge base. I have an issue with the XMLWriter object when trying to use the openURI() method. I recently installed Drupal 7 and I tried to enable the xmlsitemap module. it produced a ton of errors relating to the XMLWriter object not being valid or initialized example: Warning: XMLWriter::startDocument() [xmlwriter.startdocument]: Invalid or unitialized XMLWriter object in ...(path to test file) I quickly realized that this is a server specific issue. I tried this testing code and reproduced the error: <?php $writer = new XMLWriter(); $writer->openURI('php://output'); $writer->startDocument("1.0"); $writer->startElement("example"); $writer->startElement("specchars"); $writer->text('&'); $writer->endDocument(); $writer->flush(); ?> result Warning: XMLWriter::startDocument() [xmlwriter.startdocument]: Invalid or unitialized XMLWriter object in ...(path to test file) So I then tried to use the memory write instead with this: <?php $writer = new XMLWriter(); $writer->openMemory(); $writer->startDocument("1.0"); $writer->startElement("example"); $writer->startElement("specchars"); $writer->text('&'); $writer->endDocument(); print_r($writer->outputMemory()); $writer->flush(); ?> output <?xml version="1.0"?> <example><specchars>&</specchars></example> which works fine...... so i figured that it has to be something to do with the openURI("php://output") and my server config. I am running ubuntu server 10.10 with zend php 5.2.14 . LAMP server. I can dump the php.ini file if necessary, although i am hoping I am just missing something very obvious here. also, if i actual write to a file (ie. $writer->openURI('test.xml'), then i am able to initialize the object and it works fine), it seems to only be when i use the php:// for the uri. any thoughts? Link to comment https://forums.phpfreaks.com/topic/229447-xmlwriter-error-openuriphpoutput/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.