Re: SimpleXML addChild() namespace problem

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

 



On Jan 14, 2008 11:21 PM, Carole E. Mah <carole.mah@xxxxxxxxx> wrote:

> Yes, I tried the following:
>
> http://us3.php.net/manual/en/function.dom-domdocument-createelementns.php
>
> Same results.
>


based upon information from bug #43221, if you define the namespace
beforehand
it will work.

<?php
$xml = new SimpleXMLElement('<root xmlns:itunes="http://apple.com"/>');
$n = $xml->addChild("subtitle", "Musical Mockery", "http://apple.com";);
print_r($xml->asXml());
?>

produces:
<?xml version="1.0"?>
<root xmlns:itunes="http://apple.com";><itunes:subtitle>Musical
Mockery</itunes:subtitle></root>

-nathan

[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