Re: SimpleXML addChild() namespace problem

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

 



>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

Actually, it doesn't work.

I did exactly this, and still got:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"; version="2.0">
	<channel>
		<!-- snipping, some elements omitted ... -->
		<item>
			<title>My Title</title>
			<link>My Link</link>
			<description>My Description</description>
			<itunes:author xmlns:itunes="itunes">My Author</itunes:author>
			<itunes:subtitle xmlns:itunes="itunes">My Subtitle</itunes:subtitle>
			<!-- snipping, more elements omitted ... -->
		</item>
	</channel>
</rss>

-Carole

-- 
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