mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Add example for intermixing sub-elements and attributes
This integrates user notes 103498 and 119937. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@350605 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
9ea98fa298
commit
2716a63905
1 changed files with 34 additions and 0 deletions
|
@ -58,6 +58,40 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example xml:id="xmlwriter-write-attribute.example.intermix">
|
||||
<title>Intermixing Sub-elements and Attributes</title>
|
||||
<para>
|
||||
If writing sub-elements and attributes is intermixed, any attempt to write
|
||||
attributes after the first sub-element will fail and return false.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?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();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
<element attr1="0"><subelem>0</subelem></element>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue