downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

XMLWriter::writeCData> <XMLWriter::writeAttributeNS
[edit] Last updated: Fri, 25 May 2012

view this page in

XMLWriter::writeAttribute

xmlwriter_write_attribute

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

XMLWriter::writeAttribute -- xmlwriter_write_attribute属性全体を書き込む

説明

オブジェクト指向型

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

手続き型

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

属性全体を書き込みます。

パラメータ

xmlwriter

手続き型のコールでのみ使用します。 変更される XMLWriter resource です。 このリソースは、xmlwriter_open_uri() あるいは xmlwriter_open_memory() のコールによって取得したものです。

name

属性の名前。

value

属性の値。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

参考



add a note add a note User Contributed Notes XMLWriter::writeAttribute
Maxim at inbox dot ru 12-Feb-2012 01:01
Be careful and dont write attributes after writing text() or any content into xml element, for example
<?php
xml
->startelement("div");
xml->text("my text in div");
xml->writeattribute("id",1); // wont write because after adding text
xml->endelement();
?>
Jason Hughes 15-Apr-2011 01:37
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.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites