Re: DOM namespace prefix troubles
| From: | Rob | Date: | Wed, 02 Nov 2005 19:21:22 +0000 |
| Subject: | Re: DOM namespace prefix troubles | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224988@lists.php.net to get a copy of this message | ||
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