Ref/xmlwriter-Phpdoc专题

XMLWriter::endAttribute

xmlwriter_end_attribute

End attribute

说明

面向对象风格

public bool XMLWriter::endAttribute ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_attribute ( <span class="methodparam">XMLWriter $writer )

Ends the current attribute.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startAttribute
  • XMLWriter::startAttributeNs
  • XMLWriter::writeAttribute
  • XMLWriter::writeAttributeNs

XMLWriter::endCdata

xmlwriter_end_cdata

End current CDATA

说明

面向对象风格

public bool XMLWriter::endCdata ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_cdata ( <span class="methodparam">XMLWriter $writer )

Ends the current CDATA section.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startCdata
  • XMLWriter::writeCdata

XMLWriter::endComment

xmlwriter_end_comment

Create end comment

说明

面向对象风格

public bool XMLWriter::endComment ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_comment ( <span class="methodparam">XMLWriter $writer )

Ends the current comment.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startComment
  • XMLWriter::writeComment

XMLWriter::endDocument

xmlwriter_end_document

End current document

说明

面向对象风格

public bool XMLWriter::endDocument ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_document ( <span class="methodparam">XMLWriter $writer )

Ends the current document.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDocument

XMLWriter::endDtdAttlist

xmlwriter_end_dtd_attlist

End current DTD AttList

说明

面向对象风格

public bool XMLWriter::endDtdAttlist ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_dtd_attlist ( <span class="methodparam">XMLWriter $writer )

Ends the current DTD attribute list.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtdAttlist
  • XMLWriter::writeDtdAttlist

XMLWriter::endDtdElement

xmlwriter_end_dtd_element

End current DTD element

说明

面向对象风格

public bool XMLWriter::endDtdElement ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_dtd_element ( <span class="methodparam">XMLWriter $writer )

Ends the current DTD element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtdElement
  • XMLWriter::writeDtdElement

XMLWriter::endDtdEntity

xmlwriter_end_dtd_entity

End current DTD Entity

说明

面向对象风格

public bool XMLWriter::endDtdEntity ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_dtd_entity ( <span class="methodparam">XMLWriter $writer )

Ends the current DTD entity.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtdEntity
  • XMLWriter::writeDtdEntity

XMLWriter::endDtd

xmlwriter_end_dtd

End current DTD

说明

面向对象风格

public bool XMLWriter::endDtd ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_dtd ( <span class="methodparam">XMLWriter $writer )

Ends the DTD of the document.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

返回值

成功时返回 true, 或者在失败时返回 false

参见

  • XMLWriter::startDtd
  • XMLWriter::writeDtd

XMLWriter::endElement

xmlwriter_end_element

End current element

说明

面向对象风格

public bool XMLWriter::endElement ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_element ( <span class="methodparam">XMLWriter $writer )

Ends the current element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startElement
  • XMLWriter::writeElement

XMLWriter::endPi

xmlwriter_end_pi

End current PI

说明

面向对象风格

public bool XMLWriter::endPi ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_end_pi ( <span class="methodparam">XMLWriter $writer )

Ends the current processing instruction.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startPi
  • XMLWriter::writePi

XMLWriter::flush

xmlwriter_flush

Flush current buffer

说明

面向对象风格

public <span class="type">stringint <span class="methodname">XMLWriter::flush ([ <span class="methodparam">bool $empty<span class="initializer"> = true ] )

过程化风格

string<span class="type">int <span class="methodname">xmlwriter_flush ( <span class="methodparam">XMLWriter $writer [, bool $empty = true ] )

Flushes the current buffer.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

empty
Whether to empty the buffer or not. Default is true.

返回值

If you opened the writer in memory, this function returns the generated XML buffer, Else, if using URI, this function will write the buffer and return the number of written bytes.

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource
8.0.0 This function can no longer return false.

XMLWriter::fullEndElement

xmlwriter_full_end_element

End current element

说明

面向对象风格

public bool XMLWriter::fullEndElement ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_full_end_element ( <span class="methodparam">XMLWriter $writer )

End the current xml element. Writes an end tag even if the element is empty.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endElement

XMLWriter::openMemory

xmlwriter_open_memory

Create new xmlwriter using memory for string output

说明

面向对象风格

public bool XMLWriter::openMemory ( <span class="methodparam">void )

过程化风格

XMLWriter<span class="type">false <span class="methodname">xmlwriter_open_memory ( <span class="methodparam">void )

Creates a new XMLWriter using memory for string output.

参数

返回值

面向对象风格: 成功时返回 true, 或者在失败时返回 false

过程化风格: Returns a new XMLWriter for later use with the xmlwriter functions on success, 或者在失败时返回 false.

更新日志

版本 说明
8.0.0 This function returns now an XMLWriter instance on success. Previouly, a 资源(resource) has been returned in this case.

参见

  • XMLWriter::openUri

XMLWriter::openUri

xmlwriter_open_uri

Create new xmlwriter using source uri for output

说明

面向对象风格

public bool XMLWriter::openUri ( <span class="methodparam">string $uri )

过程化风格

XMLWriter<span class="type">false <span class="methodname">xmlwriter_open_uri ( <span class="methodparam">string $uri )

Creates a new XMLWriter using uri for the output.

参数

uri
The URI of the resource for the output.

返回值

面向对象风格: 成功时返回 true, 或者在失败时返回 false

过程化风格: Returns a new XMLWriter instance for later use with the xmlwriter functions on success, 或者在失败时返回 false.

更新日志

版本 说明
8.0.0 This function returns now an XMLWriter instance on success. Previouly, a 资源(resource) has been returned in this case.

范例

示例 #1 Direct output of XML

It is possible to directly output XML by using the php://output stream wrapper.

<?php
$out =new XMLWriter();
$out->openURI('php://output');
?>

注释

Note:

On Windows, files opened with this function are locked until the writer is released.

参见

  • XMLWriter::openMemory

XMLWriter::outputMemory

xmlwriter_output_memory

Returns current buffer

说明

面向对象风格

public string XMLWriter::outputMemory ([ <span class="methodparam">bool $flush<span class="initializer"> = true ] )

过程化风格

string <span class="methodname">xmlwriter_output_memory ( <span class="methodparam">XMLWriter $writer [, bool $flush = true ] )

Returns the current buffer.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

flush
Whether to flush the output buffer or not. Default is true.

返回值

Returns the current buffer as a string.

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::flush

XMLWriter::setIndentString

xmlwriter_set_indent_string

Set string used for indenting

说明

面向对象风格

public bool XMLWriter::setIndentString ( <span class="methodparam">string $indentation )

过程化风格

bool <span class="methodname">xmlwriter_set_indent_string ( <span class="methodparam">XMLWriter $writer , string $indentation )

Sets the string which will be used to indent each element/attribute of the resulting xml.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

indentation
The indentation string.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

注释

Note:

The indent is reset when an xmlwriter is opened.

参见

  • XMLWriter::setIndent

XMLWriter::setIndent

xmlwriter_set_indent

Toggle indentation on/off

说明

面向对象风格

public bool XMLWriter::setIndent ( <span class="methodparam">bool $enable )

过程化风格

bool <span class="methodname">xmlwriter_set_indent ( <span class="methodparam">XMLWriter $writer , bool $enable )

Toggles indentation on or off.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

enable
Whether indentation is enabled.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

范例

示例 #1 XMLWriter::setIndent and mixed Content

Enabling indentation is not suitable for mixed content, because the indent string is also inserted before inline elements.

<?php
$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(2);
$writer->startDocument();
$writer->startElement('p');
$writer->text('before');
$writer->writeElement('a', 'element');
$writer->text('after');
$writer->endElement();
$writer->endDocument();
echo $writer->outputMemory();
?>

以上例程会输出:

<?xml version="1.0"?>
<p>before <a>element</a>
after</p>

注释

Note:

The indent is reset when an xmlwriter is opened.

参见

  • XMLWriter::setIndentString

XMLWriter::startAttributeNs

xmlwriter_start_attribute_ns

Create start namespaced attribute

说明

面向对象风格

public bool XMLWriter::startAttributeNs ( <span class="methodparam"><span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace )

过程化风格

bool <span class="methodname">xmlwriter_start_attribute_ns ( <span class="methodparam">XMLWriter $writer , <span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace )

Starts a namespaced attribute.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

prefix
The namespace prefix.

name
The attribute name.

namespace
The namespace URI. If namespace is null, the namespace declaration will be omitted.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource
8.0.0 prefix is nullable now.

参见

  • XMLWriter::startAttribute
  • XMLWriter::endAttribute
  • XMLWriter::writeAttribute
  • XMLWriter::writeAttributeNs

XMLWriter::startAttribute

xmlwriter_start_attribute

Create start attribute

说明

面向对象风格

public bool XMLWriter::startAttribute ( <span class="methodparam">string $name )

过程化风格

bool <span class="methodname">xmlwriter_start_attribute ( <span class="methodparam">XMLWriter $writer , string $name )

Starts an attribute.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The attribute name.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

范例

示例 #1 Basic <span class="methodname">XMLWriter::startAttribute Usage

<?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"/>

参见

  • XMLWriter::startAttributeNs
  • XMLWriter::endAttribute
  • XMLWriter::writeAttribute
  • XMLWriter::writeAttributeNs

XMLWriter::startCdata

xmlwriter_start_cdata

Create start CDATA tag

说明

面向对象风格

public bool XMLWriter::startCdata ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_start_cdata ( <span class="methodparam">XMLWriter $writer )

Starts a CDATA.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endCdata
  • XMLWriter::writeCdata

XMLWriter::startComment

xmlwriter_start_comment

Create start comment

说明

面向对象风格

public bool XMLWriter::startComment ( <span class="methodparam">void )

过程化风格

bool <span class="methodname">xmlwriter_start_comment ( <span class="methodparam">XMLWriter $writer )

Starts a comment.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endComment
  • XMLWriter::writeComment

XMLWriter::startDocument

xmlwriter_start_document

Create document tag

说明

面向对象风格

public bool XMLWriter::startDocument ([ <span class="methodparam"><span class="type">stringnull $version = "1.0" [, <span class="methodparam"><span class="type">stringnull $encoding = null [, <span class="type">stringnull $standalone = null ]]] )

过程化风格

bool <span class="methodname">xmlwriter_start_document ( <span class="methodparam">XMLWriter $writer [, <span class="type">stringnull $version = "1.0" [, <span class="methodparam"><span class="type">stringnull $encoding = null [, <span class="type">stringnull $standalone = null ]]] )

Starts a document.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

version
The version number of the document as part of the XML declaration.

encoding
The encoding of the document as part of the XML declaration.

standalone
yes or no.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endDocument

XMLWriter::startDtdAttlist

xmlwriter_start_dtd_attlist

Create start DTD AttList

说明

面向对象风格

public bool XMLWriter::startDtdAttlist ( <span class="methodparam">string $name )

过程化风格

bool <span class="methodname">xmlwriter_start_dtd_attlist ( <span class="methodparam">XMLWriter $writer , string $name )

Starts a DTD attribute list.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The attribute list name.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endDtdAttlist
  • XMLWriter::writeDtdAttlist

XMLWriter::startDtdElement

xmlwriter_start_dtd_element

Create start DTD element

说明

面向对象风格

public bool XMLWriter::startDtdElement ( <span class="methodparam">string $qualifiedName )

过程化风格

bool <span class="methodname">xmlwriter_start_dtd_element ( <span class="methodparam">XMLWriter $writer , string $qualifiedName )

Starts a DTD element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

qualifiedName
The qualified name of the document type to create.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endDtdElement
  • XMLWriter::writeDtdElement

XMLWriter::startDtdEntity

xmlwriter_start_dtd_entity

Create start DTD Entity

说明

面向对象风格

public bool XMLWriter::startDtdEntity ( <span class="methodparam">string $name , bool $isParam )

过程化风格

bool <span class="methodname">xmlwriter_start_dtd_entity ( <span class="methodparam">XMLWriter $writer , string $name , <span class="type">bool $isParam )

Starts a DTD entity.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The name of the entity.

isParam

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endDtdEntity
  • XMLWriter::writeDtdEntity

XMLWriter::startDtd

xmlwriter_start_dtd

Create start DTD tag

说明

面向对象风格

public bool XMLWriter::startDtd ( <span class="methodparam">string $qualifiedName [, <span class="type">string<span class="type">null $publicId = null [, <span class="type">string<span class="type">null $systemId = null ]] )

过程化风格

bool <span class="methodname">xmlwriter_start_dtd ( <span class="methodparam">XMLWriter $writer , string $qualifiedName [, <span class="type">string<span class="type">null $publicId = null [, <span class="type">string<span class="type">null $systemId = null ]] )

Starts a DTD.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

qualifiedName
The qualified name of the document type to create.

publicId
The external subset public identifier.

systemId
The external subset system identifier.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endDtd
  • XMLWriter::writeDtd

XMLWriter::startElementNs

xmlwriter_start_element_ns

Create start namespaced element tag

说明

面向对象风格

public bool XMLWriter::startElementNs ( <span class="methodparam"><span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace )

过程化风格

bool <span class="methodname">xmlwriter_start_element_ns ( <span class="methodparam">XMLWriter $writer , <span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace )

Starts a namespaced element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

prefix
The namespace prefix. If prefix is null, the namespace will be omitted.

name
The element name.

namespace
The namespace URI. If namespace is null, the namespace declaration will be omitted.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endElement
  • XMLWriter::writeElementNs

XMLWriter::startElement

xmlwriter_start_element

Create start element tag

说明

面向对象风格

public bool XMLWriter::startElement ( <span class="methodparam">string $name )

过程化风格

bool <span class="methodname">xmlwriter_start_element ( <span class="methodparam">XMLWriter $writer , string $name )

Starts an element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The element name.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endElement
  • XMLWriter::writeElement

XMLWriter::startPi

xmlwriter_start_pi

Create start PI tag

说明

面向对象风格

public bool XMLWriter::startPi ( <span class="methodparam">string $target )

过程化风格

bool <span class="methodname">xmlwriter_start_pi ( <span class="methodparam">XMLWriter $writer , string $target )

Starts a processing instruction tag.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

target
The target of the processing instruction.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::endPi
  • XMLWriter::writePi

XMLWriter::text

xmlwriter_text

Write text

说明

面向对象风格

public bool XMLWriter::text ( <span class="methodparam">string $content )

过程化风格

bool <span class="methodname">xmlwriter_text ( <span class="methodparam">XMLWriter $writer , string $content )

Writes a text.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

content
The contents of the text. The characters \<, >, & and " are written as entity references (i.e. <, >, & and ", respectively). All other characters including ' are written literally. To write the special XML characters literally, or to write literal entity references, xmlwriter_write_raw has to be used.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

XMLWriter::writeAttributeNs

xmlwriter_write_attribute_ns

Write full namespaced attribute

说明

面向对象风格

public bool XMLWriter::writeAttributeNs ( <span class="methodparam"><span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace , <span class="type">string $value )

过程化风格

bool <span class="methodname">xmlwriter_write_attribute_ns ( <span class="methodparam">XMLWriter $writer , <span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace , <span class="type">string $value )

Writes a full namespaced attribute.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

prefix
The namespace prefix. If prefix is null, the namespace will be omitted.

name
The attribute name.

namespace
The namespace URI. If namespace is null, the namespace declaration will be omitted.

value
The attribute value.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::writeAttribute
  • XMLWriter::startAttribute
  • XMLWriter::startAttributeNs
  • XMLWriter::endAttribute

XMLWriter::writeAttribute

xmlwriter_write_attribute

Write full attribute

说明

面向对象风格

public bool XMLWriter::writeAttribute ( <span class="methodparam">string $name , string $value )

过程化风格

bool <span class="methodname">xmlwriter_write_attribute ( <span class="methodparam">XMLWriter $writer , string $name , <span class="type">string $value )

Writes a full attribute.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The name of the attribute.

value
The value of the attribute.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

范例

示例 #1 Intermixing Sub-elements and Attributes

If writing sub-elements and attributes is intermixed, any attempt to write attributes after the first sub-element will fail and return false.

<?php
$xml = new XMLWriter();
$xml->openMemory();

$xml->startElement('element');
$xml->writeAttribute('attr1', '0');
$xml->writeElement('subelem', '0');
var_dump($xml->writeAttribute('attr2', '0'));
$xml->endElement();

echo $xml->flush();
?>

以上例程会输出:

bool(false)
<element attr1="0"><subelem>0</subelem></element>

参见

  • XMLWriter::writeAttributeNs
  • XMLWriter::startAttribute
  • XMLWriter::startAttributeNs
  • XMLWriter::endAttribute

XMLWriter::writeCdata

xmlwriter_write_cdata

Write full CDATA tag

说明

面向对象风格

public bool XMLWriter::writeCdata ( <span class="methodparam">string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_cdata ( <span class="methodparam">XMLWriter $writer , string $content )

Writes a full CDATA.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

content
The contents of the CDATA.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

范例

示例 #1 Basic xmlwriter_write_cdata Usage

<?php
// set up the document
$xml = new XmlWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('mydoc');
$xml->startElement('myele');

// CData output
$xml->startElement('mycdataelement');
$xml->writeCData("text for inclusion as CData");
$xml->endElement();

// end the document and output
$xml->endElement();
$xml->endElement();
echo $xml->outputMemory(true);
?>

以上例程会输出:

<mydoc>
 <myele>
  <mycdataelement><![CDATA[text for inclusion as CData]​]></mycdataelement>
 </myele>
</mydoc>

参见

  • XMLWriter::startCdata
  • XMLWriter::endCdata

XMLWriter::writeComment

xmlwriter_write_comment

Write full comment tag

说明

面向对象风格

public bool XMLWriter::writeComment ( <span class="methodparam">string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_comment ( <span class="methodparam">XMLWriter $writer , string $content )

Writes a full comment.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

content
The contents of the comment.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startComment
  • XMLWriter::endComment

XMLWriter::writeDtdAttlist

xmlwriter_write_dtd_attlist

Write full DTD AttList tag

说明

面向对象风格

public bool XMLWriter::writeDtdAttlist ( <span class="methodparam">string $name , string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_dtd_attlist ( <span class="methodparam">XMLWriter $writer , string $name , <span class="type">string $content )

Writes a DTD attribute list.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The name of the DTD attribute list.

content
The content of the DTD attribute list.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtdAttlist
  • XMLWriter::endDtdAttlist

XMLWriter::writeDtdElement

xmlwriter_write_dtd_element

Write full DTD element tag

说明

面向对象风格

public bool XMLWriter::writeDtdElement ( <span class="methodparam">string $name , string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_dtd_element ( <span class="methodparam">XMLWriter $writer , string $name , <span class="type">string $content )

Writes a full DTD element.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The name of the DTD element.

content
The content of the element.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtdElement
  • XMLWriter::endDtdElement

XMLWriter::writeDtdEntity

xmlwriter_write_dtd_entity

Write full DTD Entity tag

说明

面向对象风格

public bool XMLWriter::writeDtdEntity ( <span class="methodparam">string $name , string $content [, <span class="type">bool $isParam = false [, <span class="type">string<span class="type">null $publicId = null [, <span class="type">string<span class="type">null $systemId = null [, <span class="type">string<span class="type">null $notationData<span class="initializer"> = null ]]]] )

过程化风格

bool <span class="methodname">xmlwriter_write_dtd_entity ( <span class="methodparam">XMLWriter $writer , string $name , <span class="type">string $content [, <span class="methodparam">bool $isParam<span class="initializer"> = false [, <span class="methodparam"><span class="type">stringnull $publicId = null [, <span class="type">stringnull $systemId = null [, <span class="type">stringnull $notationData = null ]]]] )

Writes a full DTD entity.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The name of the entity.

content
The content of the entity.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource
8.0.0 publicId, systemId and notationData are nullable now.

参见

  • XMLWriter::startDtdEntity
  • XMLWriter::endDtdEntity

XMLWriter::writeDtd

xmlwriter_write_dtd

Write full DTD tag

说明

面向对象风格

public bool XMLWriter::writeDtd ( <span class="methodparam">string $name [, <span class="type">stringnull $publicId = null [, <span class="type">stringnull $systemId = null [, <span class="type">stringnull $content = null ]]] )

过程化风格

bool <span class="methodname">xmlwriter_write_dtd ( <span class="methodparam">XMLWriter $writer , string $name [, <span class="type">stringnull $publicId = null [, <span class="type">stringnull $systemId = null [, <span class="type">stringnull $content = null ]]] )

Writes a full DTD.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The DTD name.

publicId
The external subset public identifier.

systemId
The external subset system identifier.

content
The content of the DTD.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startDtd
  • XMLWriter::endDtd

XMLWriter::writeElementNs

xmlwriter_write_element_ns

Write full namespaced element tag

说明

面向对象风格

public bool XMLWriter::writeElementNs ( <span class="methodparam"><span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace [, <span class="type">string<span class="type">null $content = null ] )

过程化风格

bool <span class="methodname">xmlwriter_write_element_ns ( <span class="methodparam">XMLWriter $writer , <span class="type">stringnull $prefix , <span class="type">string $name , <span class="methodparam"><span class="type">stringnull $namespace [, <span class="type">string<span class="type">null $content = null ] )

Writes a full namespaced element tag.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

prefix
The namespace prefix. If prefix is null, the namespace will be omitted.

name
The element name.

namespace
The namespace URI. If namespace is null, the namespace declaration will be omitted.

content
The element contents.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startElementNs
  • XMLWriter::endElement
  • XMLWriter::writeElement

XMLWriter::writeElement

xmlwriter_write_element

Write full element tag

说明

面向对象风格

public bool XMLWriter::writeElement ( <span class="methodparam">string $name [, <span class="type">stringnull $content = null ] )

过程化风格

bool <span class="methodname">xmlwriter_write_element ( <span class="methodparam">XMLWriter $writer , string $name [, <span class="type">stringnull $content = null ] )

Writes a full element tag.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

name
The element name.

content
The element contents.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startElement
  • XMLWriter::endElement
  • XMLWriter::writeElementNs

XMLWriter::writePi

xmlwriter_write_pi

Writes a PI

说明

面向对象风格

public bool XMLWriter::writePi ( <span class="methodparam">string $target , string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_pi ( <span class="methodparam">XMLWriter $writer , string $target , <span class="type">string $content )

Writes a processing instruction.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

target
The target of the processing instruction.

content
The content of the processing instruction.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::startPi
  • XMLWriter::endPi

XMLWriter::writeRaw

xmlwriter_write_raw

Write a raw XML text

说明

面向对象风格

public bool XMLWriter::writeRaw ( <span class="methodparam">string $content )

过程化风格

bool <span class="methodname">xmlwriter_write_raw ( <span class="methodparam">XMLWriter $writer , string $content )

Writes a raw xml text.

参数

xmlwriter
仅用于过程调用。被修改的 XMLWriter 实例对象。此资源来自于对 <span class="function">xmlwriter_open_uri 或 <span class="function">xmlwriter_open_memory 的调用。

content
The text string to write.

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 现在 writer 需要 XMLWriter 实例, 之前需要的是 resource

参见

  • XMLWriter::text

目录


本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除