Bug #12447: Function to encode strings for XML

From: Date: Sat, 28 Jul 2001 10:38:03 +0000
Subject: Bug #12447: Function to encode strings for XML
Groups: php.dev 
Request: Send a blank email to php-dev+get-61311@lists.php.net to get a copy of this message
From: sbergmann@php.net Operating system: PHP version: 4.0.6 PHP Bug Type: Feature/Change Request Bug description: Function to encode strings for XML Currently I use function &xml_encode(&$xml) { $xml = str_replace(array('ü', 'Ü', 'ö', 'Ö', 'ä', 'Ä', 'ß' ), array('&#252;', '&#220;', '&#246;', '&#214;', '&#228;', '&#196;', '&#223;' ), $xml ); $xml = preg_replace(array("/\&([a-z\d\#]+)\;/i", "/\&/", "/\#\|\|([a-z\d\#]+)\|\|\#/i", "/([^a-zA-Z\d\s\<\>\&\;\.\:\=\"\-\/\%\?\!\'\(\)\[\]\{\}\$\#\+\,\@_])/e" ), array("#||\\1||#", "&amp;", "&\\1;", "'&#'.ord('\\1').';'" ), $xml ); return $xml; } to 'encode' strings for use with XML. A 'PHP Land' implementation of this would be handy, I think. -- Edit bug report at: http://bugs.php.net/?id=12447&edit=1

« previous php.dev (#61311) next »