note 92881 added to class.domdocumentfragment

From: Date: Wed, 12 Aug 2009 22:43:09 +0000
Subject: note 92881 added to class.domdocumentfragment
Groups: php.notes 
Request: Send a blank email to php-notes+get-159416@lists.php.net to get a copy of this message
I found DOMDocument very useful for extracting raw XML from a field in a MySQL database. The following always gave me character entities for the XML tag brackets (< >) in the output (whether I used the utf8_encode function or htmlspecialchars function or neither of them on $row['text']): $next_elem = $doc->createElement( $row['node_type'], utf8_encode($row['text']) ); $section_elem->appendChild($next_elem); I changed the code to use a DOMDocumentFragment and now the XML I stored in my database comes out as XML in my output with proper tag brackets instead of html character entities: $next_elem = $doc->createDocumentFragment(); $next_elem->appendXML($row['text']); $section_elem->appendChild($next_elem); ---- Server IP: 217.160.72.57 Probable Submitter: 91.208.107.59 ---- Manual Page -- http://www.php.net/manual/en/class.domdocumentfragment.php Edit -- https://master.php.net/note/edit/92881 Del: integrated -- https://master.php.net/note/delete/92881/integrated Del: useless -- https://master.php.net/note/delete/92881/useless Del: bad code -- https://master.php.net/note/delete/92881/bad+code Del: spam -- https://master.php.net/note/delete/92881/spam Del: non-english -- https://master.php.net/note/delete/92881/non-english Del: in docs -- https://master.php.net/note/delete/92881/in+docs Del: other reasons-- https://master.php.net/note/delete/92881 Reject -- https://master.php.net/note/reject/92881 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159416) next »