(PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL xmlwriter >= 0.1.0)
XMLWriter::startAttribute -- xmlwriter_start_attribute — 创建开始属性
面向对象风格
过程化风格
开始一个属性。
示例 #1 基本XMLWriter::startAttribute()用法
<?php
$writer = new XMLWriter;
$writer->openURI('php://output');
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('element');
$writer->startAttribute('attribute');
$writer->text('value');
$writer->endAttribute();
$writer->endElement();
$writer->endDocument();
以上示例将输出类似于以下内容
<?xml version="1.0" encoding="UTF-8"?> <element attribute="value"/>