Bug in XMLWriter?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am using XMLWriter with PHP 5.1.4 and find that it doesn't behave as I expect. I am under the impressing that until I call 'endElement', I should be free to continue adding attributes to an opened element regardless of whether I have already added elements or text below it. Look at this sample code:

<?php
//--------------------------------------------------
// create an object to write to an in-memory buffer
$XML = new XMLWriter();
$XML->openMemory();

// start new element and add 1 attribute
$XML->startElement("a");
$XML->writeAttribute("href", "http://www.google.com";);

// add a text node
$XML->text("Google");

// add another attribute (DOES NOT WORK)
$XML->writeAttribute("target", "_blank");

// add more text
$XML->text(" Go There");

// end the element and output so we can see what we have
$XML->endElement();
print htmlspecialchars($XML->outputMemory());
//--------------------------------------------------
?>

output: <a href="http://www.google.com";>Google Go There</a>

If you notice, the 'target="_blank"' attribute was silently ignored. However, if I move that statement above the ->text() method call, it will work as expected. Is this a bug or a feature I don't know about?

Dante

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux