Re: DOM namespace prefix troubles
| From: | Ace McKool | Date: | Wed, 02 Nov 2005 22:46:45 +0000 |
| Subject: | Re: DOM namespace prefix troubles | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-225001@lists.php.net to get a copy of this message | ||
Thanks Rob! That solved my probem. Thanks again!
On 11/2/05, Rob <rrichards@ctindustries.net> wrote:
>
> Ace McKool wrote:
>
> > What I'm trying to create is something like the following:
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <Notes xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:
> > CommonAggregateComponents-1.0">
> > <cac:Note />
> > </Notes>
> > I am unable to create the "<cac:Note />" element with the "cac:"
> namespace
> > prefix. Any suggestions would be appreciated!
> >
>
> $dom = new DOMDocument("1.0", "UTF-8");
> $root = $dom->createElement('Notes');
> $dom->appendChild($root);
>
>
> $root->setAttributeNS("http://www.w3.org/2000/xmlns/",
> 'xmlns:cac',
>
> 'urn:oasis:names:specification:ubl:schema:xsd:
> CommonAggregateComponents-1.0');
>
> $child =
> $dom->createElementNS('urn:oasis:names:specification:ubl:schema:xsd:
> CommonAggregateComponents-1.0',
>
> 'cac:Note');
>
> $root->appendChild($child);
>
> Hope that helps.
>
> Rob
>
>