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