This example shows how to work with XMLWriter's object-oriented API.
Exemplo #1 Working with the OO API
<?php
$xw = new XMLWriter();
$xw->openMemory();
$xw->startDocument("1.0");
$xw->startElement("book");
$xw->text("example");
$xw->endElement();
$xw->endDocument();
echo $xw->outputMemory();
O exemplo acima produzirá:
<?xml version="1.0"?> <book>example</book>