create xml root-element with xmlns and xsd link (using DOM)

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

 



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

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