<?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()); ?>
Output skrev:<?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>
Ønsket output skrev:<?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>
<?php
$XML = new DOMDocument("1.0", "UTF-8");
$Atom = $XML->appendChild($XML->createElementNS("http://www.w3.org/2005/Atom", "feed"));
$Atom->setAttribute('xmlns:xht', 'http://www.w3.org/1999/xhtml');
$XHTML = $Atom->appendChild($XML->createElement("xht:strong", "fet tekst"));
$XML->formatOutput = true;
printf($XML->saveXML());
?>
<?php
$XML = new DOMDocument("1.0", "UTF-8");
$Atom = $XML->appendChild($XML->createElementNS("http://www.w3.org/2005/Atom", "feed"));
$Atom->setAttribute("xmlns:xht", "http://www.w3.org/1999/xhtml");
$Entry = $Atom->appendChild($XML->createElement("entry"));
$EntrySummary = $Entry->appendChild($XML->createElement("summary"));
$EntrySummary->setAttribute("type", "xhtml");
$EntrySummary->appendXML("<xht:p>XHTML paragraf 1</xht:p><xht:p>annen paragraf</xht:p>");
$XML->formatOutput = true;
printf($XML->saveXML());
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:xht="http://www.w3.org/1999/xhtml">
<entry>
<summary type="xhtml">
<xht:p>XHTML paragraf 1</xht:p>
<xht:p>annen paragraf</xht:p>
</summary>
</entry>
</feed>
setAttributeNS("http://www.w3.org/2000/xmlns", "xmlns:xht", "http://www.w3.org/1999/xhtml");
Registrerte brukere: Google [Bot]