blob: 6d26c581e19cdb7df5b8961b7e69000d90ad141e [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
Derek Jonese7dfb672013-07-19 14:16:56 -070031 :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;
Derek Jones22c9b802013-07-19 15:38:06 -070033 :returns: string
Derek Jones8ede1a22011-10-05 13:34:52 -050034
Derek Jonese7dfb672013-07-19 14:16:56 -070035 Takes a string as input and converts the following reserved XML
36 characters to entities:
Derek Jones8ede1a22011-10-05 13:34:52 -050037
Derek Jonese7dfb672013-07-19 14:16:56 -070038 - Ampersands: &
39 - Less then and greater than characters: < >
40 - Single and double quotes: ' "
41 - Dashes: -
Derek Jones8ede1a22011-10-05 13:34:52 -050042
Derek Jonese7dfb672013-07-19 14:16:56 -070043 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
Derek Jonese7dfb672013-07-19 14:16:56 -070046 $string = '<p>Here is a paragraph & an entity (&#123;).</p>';
47 $string = xml_convert($string);
48 echo $string;
49
50 outputs:
51
52 .. code-block:: html
53
54 &lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;