create xml root-element with xmlns and xsd link (using DOM)
| From: | Andreas Korthaus | Date: | Sun, 05 Mar 2006 20:51:40 +0000 |
| Subject: | create xml root-element with xmlns and xsd link (using DOM) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231489@lists.php.net to get a copy of this message | ||
Hi!
The XML-Code I have to create (http://news.php.net/php.general/231486), needs a root-element, with xmlns and XML schema link, something like that:
<Test xmlns="http://example.com/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.com/test
test.xsd">
Does DOM provide any means to add a XML schema link to the doc?
Now I'm doing it this way (which seems to work):
<?php
$doc = new DOMDocument;
$root = $doc->appendChild(new DOMElement('root', NULL,
'http://example.com/test'));
$root->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation', 'http://example.com/test test.xsd');
echo $doc->savexml();
?>
Does DOM provide nothing else?
Does anybody see any problems with this approach?
Best regards
Andreas