note 78929 added to ref.dom

From: Date: Fri, 02 Nov 2007 18:02:45 +0000
Subject: note 78929 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-131951@lists.php.net to get a copy of this message
In order to REALLY well handle XHTML entities with DOM, you can do following things: 1. Add this DOCTYPE to your documents <!DOCTYPE xhtmlentities PUBLIC "-//W3C//ENTITIES XHTML Character Entities 1.0//EN" "/xhtml11.ent"> 2. Copy http://freyjkell.ovh.org/xhtml11.ent into your document root. 3. In your PHP: <?php $dom=new DOMDocument(); $dom->load('file.xhtml',LIBXML_DTDLOAD); // NOT resolveExternals - it needs true doctype, and includes crap code // some DOM operations $doctype=DOMImplementation::createDocumentType("html","-//W3C//DTD XHTML 1.1//EN","http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"); // creating real doctype $output=DOMImplementation::createDocument('','',$doctype); $output->appendChild($output->importNode($dom->documentElement,true)); $output->encoding='utf-8'; $output=$output->saveXML(); $xhtml=preg_match( '/application\/xhtml\+xml(?![+a-z])'. '(;q=(0\.\d{1,3}|[01]))?/i', $_SERVER['HTTP_ACCEPT'],$xhtml) && (isset($xhtml[2])?$xhtml[2]:1) > 0 || strpos($_SERVER["HTTP_USER_AGENT"], "W3C_Validator")!==false || strpos($_SERVER["HTTP_USER_AGENT"], "WebKit")!==false; // XHTML Content-Negotiation header('Content-Type: '.($xhtml?'application/xhtml+xml':'text/html').'; charset=utf-8'); print $output; ?> ---- Server IP: 195.136.184.34 Probable Submitter: 83.4.24.47 ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- https://master.php.net/note/edit/78929 Del: integrated -- https://master.php.net/note/delete/78929/integrated Del: useless -- https://master.php.net/note/delete/78929/useless Del: bad code -- https://master.php.net/note/delete/78929/bad+code Del: spam -- https://master.php.net/note/delete/78929/spam Del: non-english -- https://master.php.net/note/delete/78929/non-english Del: in docs -- https://master.php.net/note/delete/78929/in+docs Del: other reasons-- https://master.php.net/note/delete/78929 Reject -- https://master.php.net/note/reject/78929 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131951) next »