XMLWriter::setIndent

xmlwriter_set_indent

(PHP 5 >= 5.1.2, PHP 7, PECL xmlwriter >= 0.1.0)

XMLWriter::setIndent -- xmlwriter_set_indentToggle indentation on/off

Descrição

Estilo orientado à objeto

public XMLWriter::setIndent ( bool $enable ) : bool

Estilo procedural

xmlwriter_set_indent ( XMLWriter $writer , bool $enable ) : bool

Toggles indentation on or off.

Parâmetros

xmlwriter

Apenas para chamadas de procedimentos. O recurso XMLWriter resource que esta sendo modificado. Este recurso vem de uma chamada a xmlwriter_open_uri() ou xmlwriter_open_memory().

enable

Whether indentation is enabled.

Valor Retornado

Retorna true em caso de sucesso ou false em caso de falha.

Changelog

Versão Descrição
8.0.0 writer expects an XMLWriter instance now; previously, a resource was expected.

Exemplos

Exemplo #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();
?>

O exemplo acima irá imprimir:

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

Notas

Nota:

The indent is reset when an xmlwriter is opened.

Veja Também

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top