public function execute($input) { $this->isRoot = true; $this->writer = new XMLWriter(); $this->writer->openMemory(); $this->writer->startDocument('1.0', 'UTF-8'); $this->writer->setIndent(true); $this->run($input); return $this->writer->flush(); }
/** * writeObject will write the RSS representation of Object. * * @param object $object * * @throws \LogicException if no writer can handle $object or if $object is not an object */ public function writeObject($object) { if (!is_object($object)) { throw new \LogicException(sprintf('%s::%s expects an object. %s given.', __CLASS_, __METHOD__, gettype($object))); } $fqcn = get_class($object); if (!isset($this->writers[$fqcn])) { throw new \LogicException(sprintf('No writer found for class %s', $fqcn)); } call_user_func($this->writers[$fqcn], $this, $object); if ($this->flushEarly) { $this->xmlWriter->flush(); } }
public function flush() { $this->cursor->endDocument(); return $this->cursor->flush(); }
public function flush() { $this->writer->flush(); }
<?php $xml = new XmlWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->startDocument(); $xml->startElement('test'); $xml->writeElement('foo', null); $xml->writeElement('foo2', ""); $xml->writeElement('foo3'); $xml->startElement('bar'); $xml->endElement('bar'); $xml->endElement(); $xml->endElement(); print $xml->flush(true); print "\n"; $xw = new XMLWriter(); $xw->openMemory(); $xw->setIndent(true); $xw->startDocument(); $xw->startElementNS('test', 'test', 'urn:x-test:'); $xw->writeElementNS('test', 'foo', null, ''); $xw->writeElementNS(null, 'bar', 'urn:x-test:', ''); $xw->writeElementNS(null, 'bar', 'urn:x-test:', NULL); $xw->writeElementNS(null, 'bar', 'urn:x-test:'); $xw->writeElementNS(null, 'bar', '', ''); $xw->endElement(); $xw->endDocument(); print $xw->flush(true);
/** * The parameter is merely to comply with PHP's notion that I am * overriding the parent's flush, so I should provide the same * signature. Nor am I not, but, even if I was, PHP should allow * different signatures, i.e., enable both methods to be called... * * @see XMLWriter::flush() */ public function flush($empty = true) { parent::endDocument(); return parent::flush($empty); }