Click to See Complete Forum and Search --> : Php Dom Xml->xmlns


Moldarin
01-28-2008, 08:31 PM
Hi, ☺

How do I use PHP DOM XML to output all XMLNS declared troughout the DOM to the root element? See below code, and the actual output and the desired output.

<?php
$XML = new DOMDocument("1.0", "UTF-8");
$Atom = $XML->appendChild($XML->createElementNS("http://www.w3.org/2005/Atom", "feed"));
$Atom->appendChild($XML->createElementNS("http://www.w3.org/1999/xhtml", "xht:strong", "fet tekst"));
$Atom->appendChild($XML->createElementNS("http://www.w3.org/1999/xhtml", "xht:strong", "fet tekst2"));
$XML->formatOutput = true;
printf($XML->saveXML()); ?>
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<xht:strong xmlns:xht="http://www.w3.org/1999/xhtml">fet tekst</xht:strong>
<xht:strong xmlns:xht="http://www.w3.org/1999/xhtml">fet tekst2</xht:strong>
</feed>
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xht="http://www.w3.org/1999/xhtml">
<xht:strong>fet tekst</xht:strong>
<xht:strong>fet tekst2</xht:strong>
</feed>