blob: 903e925c2954f07fd4ce835be8c1e4d24bd1cb7a [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001##########
2XML Helper
3##########
4
5The XML Helper file contains functions that assist in working with XML
6data.
7
Derek Jonese7dfb672013-07-19 14:16:56 -07008.. contents::
9 :local:
Derek Jones8ede1a22011-10-05 13:34:52 -050010
Derek Jones65d4f7e2013-07-19 15:35:36 -070011.. raw:: html
12
13 <div class="custom-index container"></div>
14
Derek Jones8ede1a22011-10-05 13:34:52 -050015Loading this Helper
16===================
17
18This helper is loaded using the following code
19
20::
21
22 $this->load->helper('xml');
23
Derek Jonese7dfb672013-07-19 14:16:56 -070024Available Functions
25===================
26
Derek Jones8ede1a22011-10-05 13:34:52 -050027The following functions are available:
28
Andrey Andreevcd3d9db2015-02-02 13:41:01 +020029.. php:function:: xml_convert($str[, $protect_all = FALSE])
Derek Jones8ede1a22011-10-05 13:34:52 -050030
Andrey Andreevba231aa2014-01-20 16:43:41 +020031 :param string $str: the text string to convert
32 :param bool $protect_all: Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo;
Andrey Andreev3de130c2014-02-07 23:31:49 +020033 :returns: XML-converted string
34 :rtype: string
Derek Jones8ede1a22011-10-05 13:34:52 -050035
Andrey Andreevba231aa2014-01-20 16:43:41 +020036 Takes a string as input and converts the following reserved XML
37 characters to entities:
Derek Jones8ede1a22011-10-05 13:34:52 -050038
Andrey Andreevba231aa2014-01-20 16:43:41 +020039 - Ampersands: &
40 - Less than and greater than characters: < >
41 - Single and double quotes: ' "
42 - Dashes: -
Derek Jones8ede1a22011-10-05 13:34:52 -050043
Andrey Andreevba231aa2014-01-20 16:43:41 +020044 This function ignores ampersands if they are part of existing numbered
45 character entities, e.g. &#123;. Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050046
Andrey Andreevba231aa2014-01-20 16:43:41 +020047 $string = '<p>Here is a paragraph & an entity (&#123;).</p>';
48 $string = xml_convert($string);
49 echo $string;
Derek Jonese7dfb672013-07-19 14:16:56 -070050
Andrey Andreevba231aa2014-01-20 16:43:41 +020051 outputs:
Derek Jonese7dfb672013-07-19 14:16:56 -070052
Andrey Andreevba231aa2014-01-20 16:43:41 +020053 .. code-block:: html
Derek Jonese7dfb672013-07-19 14:16:56 -070054
Andrey Andreev3de130c2014-02-07 23:31:49 +020055 &lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;