Re: SimpleXML addChild() namespace problem
| From: | Nathan Nobbe | Date: | Tue, 15 Jan 2008 04:01:49 +0000 |
| Subject: | Re: SimpleXML addChild() namespace problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267273@lists.php.net to get a copy of this message | ||
On Jan 14, 2008 10:22 PM, Carole E. Mah <carole.mah@gmail.com> wrote:
> This is problematic code, even though it works, because it
> auto-generates an unnecessary xmlns: attribute:
>
> $item->addChild('itunes:subtitle', $mySubTitle,"itunes");
>
> It generates the following XML:
>
> <itunes:subtitle xmlns:itunes="itunes">Musical Mockery</itunes:subtitle>
>
> When really all we want is this:
>
> <itunes:subtitle>Musical Mockery</itunes:subtitle>
>
> Furthermore, dumping it into a DomDocument and attempting to use
> removeAttributeNS() to remove the spurious attribute removes the
> entire kit and kaboodle, leaving only:
>
> <subtitle>Musical Mockery</subtitle>
>
> How can one get the desired result, short of using a regexp? (I have
> done this, and it works, but is a silly hack because it doesn't use
> XML parsing to address an XML problem).
have you considered appending the child w/ w/e the DOM extension
has, just to see if the namespace specification is unintentionally added
by it as well?
-nathan