blob: 7d155e192c089ce093ac6b6f25153389a50b3d0a [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
Derek Jones261ba1c2013-07-19 16:01:32 -070029.. 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;
33 :returns: string
Derek Jones8ede1a22011-10-05 13:34:52 -050034
Andrey Andreevba231aa2014-01-20 16:43:41 +020035 Takes a string as input and converts the following reserved XML
36 characters to entities:
Derek Jones8ede1a22011-10-05 13:34:52 -050037
Andrey Andreevba231aa2014-01-20 16:43:41 +020038 - Ampersands: &
39 - Less than and greater than characters: < >
40 - Single and double quotes: ' "
41 - Dashes: -
Derek Jones8ede1a22011-10-05 13:34:52 -050042
Andrey Andreevba231aa2014-01-20 16:43:41 +020043 This function ignores ampersands if they are part of existing numbered
44 character entities, e.g. &#123;. Example::
Derek Jones8ede1a22011-10-05 13:34:52 -050045
Andrey Andreevba231aa2014-01-20 16:43:41 +020046 $string = '<p>Here is a paragraph & an entity (&#123;).</p>';
47 $string = xml_convert($string);
48 echo $string;
Derek Jonese7dfb672013-07-19 14:16:56 -070049
Andrey Andreevba231aa2014-01-20 16:43:41 +020050 outputs:
Derek Jonese7dfb672013-07-19 14:16:56 -070051
Andrey Andreevba231aa2014-01-20 16:43:41 +020052 .. code-block:: html
Derek Jonese7dfb672013-07-19 14:16:56 -070053
Andrey Andreevba231aa2014-01-20 16:43:41 +020054 &lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;