From:             [EMAIL PROTECTED]
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('ü', 'Ü', 'ö',
                           'Ö', 'ä', 'Ä',
                           'ß'
                          ),
                     $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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to