Bug #68756 [Opn]: attributes added after subelements are ignored
| From: | requinix@php.net | Date: | Tue, 06 Jan 2015 01:25:02 +0000 |
| Subject: | Bug #68756 [Opn]: attributes added after subelements are ignored | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11829@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68756&edit=1
ID: 68756
Updated by: requinix@php.net
Reported by: bas5winkel at gmail dot com
Summary: attributes added after subelements are ignored
Status: Open
Type: Bug
-Package: XML Writer
+Package: Documentation problem
Operating System: all?
PHP Version: 5.5.20
Block user comment: N
Private report: N
New Comment:
XMLWriter is a stream writer: once you've started writing a subelement you cannot "go
back" and write an attribute.
Changing to a doc bug as I don't see this caveat mentioned anywhere.
Previous Comments:
------------------------------------------------------------------------
[2015-01-06 00:58:29] bas5winkel at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.xmlwriter-write-attribute
---
If you intermix writing sub-elements and attributes, any attributes that are written after the first
sub-element are ignored/discarded.
Test script:
---------------
<?php
$xml->startElement('element');
$xml->writeAttribute('attr1', 0);
$xml->writeElement('subelem', 0);
$xml->writeAttribute('attr2', 0);
$xml->endElement();
?>
Expected result:
----------------
<element attr1=0 attr2=0>
<subelem>0</subelem>
</element>
Actual result:
--------------
<element attr1=0>
<subelem>0</subelem>
</element>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68756&edit=1