I'm trying to produce the following XML by means of DOM/PHP5:
<?xml version="1.0"?>
<root xmlns:p="myNS">
<p:x>test</p:x>
</root>
This is what I'm doing:
$xml = new DOMDocument('1.0');
$root = $xml->createElementNS('myNS', 'root');
$xml->appendChild($root);
$x = $xml->createElementNS('myNS', 'x', 'test');
$root->appendChild($x);
echo $xml->saveXML();
This is what I'm getting:
<?xml version="1.0"?>
<root xmlns="myNS">
<x>test</x>
</root>
What am I doing wrong? How to make this prefix working?