Source for file xml_functions.php

Documentation is available at xml_functions.php

  1. <?php
  2. /**
  3.  * CodeIgniter
  4.  *
  5.  * An open source application development framework for PHP 4.3.2 or newer
  6.  *
  7.  * @package        CodeIgniter
  8.  * @subpackage     Helpers
  9.  * @author        ExpressionEngine Dev Team
  10.  * @copyright    Copyright (c) 2006, EllisLab, Inc.
  11.  * @license        http://codeigniter.com/user_guide/license.html
  12.  * @link        http://codeigniter.com
  13.  * @since        Version 1.0
  14.  * @filesource
  15.  */
  16.  
  17. // ------------------------------------------------------------------------
  18.  
  19. /**
  20.  * CodeIgniter XML Helpers
  21.  *
  22.  * @author        ExpressionEngine Dev Team
  23.  * @link        http://codeigniter.com/user_guide/helpers/xml_helper.html
  24.  */
  25.  
  26. // ------------------------------------------------------------------------
  27.  
  28. if (function_exists('xml_convert')) {
  29.     /**
  30.      * Convert Reserved XML characters to Entities
  31.      *
  32.      * @access    public
  33.      * @param    string 
  34.      * @return    string 
  35.      */    
  36.     function xml_convert($str)
  37.     {
  38.         $temp '__TEMP_AMPERSANDS__';
  39.  
  40.         // Replace entities to temporary markers so that 
  41.         // ampersands won't get messed up
  42.         $str preg_replace("/&#(\d+);/""$temp\\1;"$str);
  43.         $str preg_replace("/&(\w+);/",  "$temp\\1;"$str);
  44.     
  45.         $str str_replace(array("&","<",">","\"""'""-"),
  46.                            array("&amp;""&lt;""&gt;""&quot;""&#39;""&#45;"),
  47.                            $str);
  48.  
  49.         // Decode the temp markers back to entities        
  50.         $str preg_replace("/$temp(\d+);/","&#\\1;",$str);
  51.         $str preg_replace("/$temp(\w+);/","&\\1;"$str);
  52.         
  53.         return $str;
  54.     }
  55. }
  56.  
  57. ?>

Documentation generated on Tue, 22 Nov 2011 13:29:04 -0200 by phpDocumentor 1.4.3