blob: ee3fc289b102c6a24d097377e87914cea2078697 [file] [log] [blame]
adminb0dd10f2006-08-25 17:25:49 +00001<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Code Igniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author Rick Ellis
9 * @copyright Copyright (c) 2006, pMachine, Inc.
10 * @license http://www.codeignitor.com/user_guide/license.html
11 * @link http://www.codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Code Igniter XML Helpers
20 *
21 * @package CodeIgniter
22 * @subpackage Helpers
23 * @category Helpers
24 * @author Rick Ellis
25 * @link http://www.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 */
37function xml_convert($str)
38{
39 $temp = '__TEMP_AMPERSANDS';
40
41 $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
42 $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
43
44 $str = str_replace(array("&","<",">","\"", "'", "-"),
45 array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
46 $str);
47
48 $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
49 $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
50
51 return $str;
52}
53
54
55?>