Re: DOM namespace prefix troubles

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

 



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

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