note 92881 deleted from class.domdocumentfragment by googleguy

From: Date: Tue, 22 Oct 2013 11:15:46 +0000
Subject: note 92881 deleted from class.domdocumentfragment by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197049@lists.php.net to get a copy of this message
Note Submitter: mary dot kalinosky at thieme dot com ---- 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 (&lt; &gt;) in the output (whether I used the utf8_encode function or htmlspecialchars function or neither of them on $row['text']): <?php $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: <?php $next_elem = $doc->createDocumentFragment(); $next_elem->appendXML($row['text']); $section_elem->appendChild($next_elem); ?>

« previous php.notes (#197049) next »