Search the Community
Showing results for tags 'xmlwriter'.
-
As part of a larger project, I'm trying to generate an xml file using xmlWriter. The file is created and looks okay but I get an error - "This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error." The rest of the page is blank. The source code only displays my error message "Problems creating file "fcTeams.xml". I've include a simplified version of my code which is where the error is coming from. Any ideas what's causing the error? $xml = new XMLWriter(); $xml->openUri('fcTeams.xml'); $xml->setIndent(true); $xml->setIndentString("\t"); $xml->startDocument(); $xml->startElement('teams'); $xml->startElement('fc'); $xml->writeAttribute('id', '03'); $xml->writeElement('name', 'Real Madrid'); $xml->writeElement('manager', 'Jose Mourinho'); $xml->writeElement('captain', 'Iker Casillas'); $xml->writeElement('stadium', 'Bernabeu'); $xml->startElement('player'); $xml->writeElement('name' , 'Christiano Ronaldo'); $xml->writeElement('position','forward'); $xml->writeElement('number','7'); $xml->writeElement('country','Portugal'); $xml->endElement(); $xml->startElement('player'); $xml->writeElement('name' , 'Kaka'); $xml->writeElement('position','midfielder'); $xml->writeElement('number','8'); $xml->writeElement('country','Brazil'); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); header ('Content-type: text/xml'); if ($xml->flush() ) { echo 'File "fcTeams.xml" created.'; } else { echo 'Problems creating file "fcTeams.xml".'; }