php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12447 Function to encode strings for XML
Submitted: 2001-07-28 06:38 UTC Modified: 2002-11-30 09:20 UTC
From: sbergmann@php.net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sbergmann@php.net
New email:
PHP Version: OS:

 

 [2001-07-28 06:38 UTC] sbergmann@php.net
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-30 09:20 UTC] chregu@php.net
ext/recode has an XML mode. Maybe that helps (not sure about windows, though)

chregu
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 18 08:03:18 2022 UTC