PHP 5.4.31 Released

XMLWriter::writeAttribute

xmlwriter_write_attribute

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

XMLWriter::writeAttribute -- xmlwriter_write_attributeWrite full attribute

Descrizione

Stile orientato agli oggetti

bool XMLWriter::writeAttribute ( string $name , string $value )

Stile procedurale

bool xmlwriter_write_attribute ( resource $xmlwriter , string $name , string $value )

Writes a full attribute.

Elenco dei parametri

xmlwriter

Solo per chiamate procedurali. La resource XMLWriter che รจ stata modificata. Questa risorsa deriva da una chiamata a xmlwriter_open_uri() or xmlwriter_open_memory().

name

The name of the attribute.

value

The value of the attribute.

Valori restituiti

Restituisce TRUE in caso di successo, FALSE in caso di fallimento.

Vedere anche:

add a note add a note

User Contributed Notes 1 note

up
1
Jason Hughes
3 years ago
If you intermix writing sub-elements and attributes, any attributes that are written after the first sub-element are ignored/discarded:

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

Outputs:

<element attr1=0>
  <subelem>0</subelem>
</element>

This is stupid, but the way it works as of PHP 5.2.4.
To Top