Bug #68756 [Opn]: attributes added after subelements are ignored

From: Date: Tue, 06 Jan 2015 14:45:43 +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-11832@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 User updated by: bas5winkel at gmail dot com Reported by: bas5winkel at gmail dot com Summary: attributes added after subelements are ignored Status: Open Type: Bug Package: Documentation problem Operating System: all? PHP Version: 5.5.20 Block user comment: N Private report: N New Comment: Thanks for the quick reply. Would it be possible to thrown an exception when one tries write an attribute after a sub-element is written? This would make it more obvious that one does something that is not possible. It took me quite a while to figure out my mistake. Previous Comments: ------------------------------------------------------------------------ [2015-01-06 01:25:02] requinix@php.net 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. ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#11832) next »