Mega Code Archive

 
Categories / Php / XML
 

Use the createTextNode() method to add multiple text strings to a body element in an HTML document

<?php $root = new DomDocument('1.0', 'iso-8859-1'); $html = $root->createElement("html"); $body = $root->createElement("body"); $txt = $root->createTextNode(utf8_encode("Danish characters ?\n")); $body->appendChild($txt); $txt = $root->createTextNode(utf8_encode("&")); $body->appendChild($txt); $html->appendChild($body); $root->appendChild($html); echo $root->saveHTML(); ?>