array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'example.xmlwriter-oop.php', 1 => 'Working with the OO API', ), 'up' => array ( 0 => 'xmlwriter.examples.php', 1 => '示例', ), 'prev' => array ( 0 => 'example.xmlwriter-namespace.php', 1 => 'Working with XML namespaces', ), 'next' => array ( 0 => 'class.xmlwriter.php', 1 => 'XMLWriter', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/xmlwriter/examples.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
This example shows how to work with XMLWriter's object-oriented API.
示例 #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();
以上示例会输出:
<?xml version="1.0"?> <book>example</book>