PHP - Manual: Working with the OO API
2024-11-13
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>
官方地址:https://www.php.net/manual/en/example.xmlwriter-oop.php