note 83673 rejected from ref.xmlwriter by felipe
| From: | felipe@php.net | Date: | Fri, 06 Jun 2008 22:57:01 +0000 |
| Subject: | note 83673 rejected from ref.xmlwriter by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140198@lists.php.net to get a copy of this message | ||
Note Submitter: hcse at op dot pl
----
Missing attributes??
<?php
header("Content-type: text/xml");
$xml = new XMLWriter();
$xml->startElement('test');
$xml->startElement('with-two-attr');
$xml->writeAttribute('exists', 'true');
$xml->writeAttribute('and', 'another');
$xml->writeElement('fine', 'no problem here :)');
$xml->endElement();
$xml->startElement('with-one-attr');
$xml->writeAttribute('exists', 'true');
$xml->writeElement('error', 'problem is here :(');
$xml->writeAttribute('and', 'another');
$xml->endElement();
$xml->endElement();
echo $xml->outputMemory(true);
?>
This code gives the result:
<test>
<with-two-attr exists="true" and="another">
<fine>no problem here :)</fine>
</with-two-attr>
<with-one-attr exists="true">
<error>problem is here :(</error>
</with-one-attr>
</test>
What we can see is that second attribute of 'with-one-attr' is missing. This always
happens when you want to add attributes after inserting some data(element/text) into element.