note 99012 added to domimplementation.createdocument

From: Date: Thu, 22 Jul 2010 07:48:08 +0000
Subject: note 99012 added to domimplementation.createdocument
Groups: php.notes 
Request: Send a blank email to php-notes+get-171035@lists.php.net to get a copy of this message
To add on to the other example, here's how to create an XHTML 1.0 transitional document with head, title, and body elements. <?php $document = DOMImplementation::createDocument(null, 'html', DOMImplementation::createDocumentType("html", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")); $document->formatOutput = true; $html = $document->documentElement; $head = $document->createElement('head'); $title = $document->createElement('title'); $text = $document->createTextNode('Title of Page'); $body = $document->createElement('body'); $title->appendChild($text); $head->appendChild($title); $html->appendChild($head); $html->appendChild($body); echo $document->saveXML(); ?> This outputs: (http links removed due to spam) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "doctype.dtd"> <html xmlns="w3org1999xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Title of Page</title> </head> <body></body> </html> Note the saveXML function. If saveHTML was used instead, you get the output: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "doctype.dtd"> <html> <head><title>Title of Page</title></head> <body></body> </html> ---- Server IP: 69.147.83.197 Probable Submitter: 68.104.11.94 ---- Manual Page -- http://www.php.net/manual/en/domimplementation.createdocument.php Edit -- https://master.php.net/note/edit/99012 Del: integrated -- https://master.php.net/note/delete/99012/integrated Del: useless -- https://master.php.net/note/delete/99012/useless Del: bad code -- https://master.php.net/note/delete/99012/bad+code Del: spam -- https://master.php.net/note/delete/99012/spam Del: non-english -- https://master.php.net/note/delete/99012/non-english Del: in docs -- https://master.php.net/note/delete/99012/in+docs Del: other reasons-- https://master.php.net/note/delete/99012 Reject -- https://master.php.net/note/reject/99012 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171035) next »