ExpressionEngine Docs

XML Helper

The XML Helper file contains functions that assist in working with XML data. This helper is loaded using the following code:

ee()->load->helper('xml');

Available Functions

xml_convert($str[, $protect_all = FALSE])

Parameter Type Description
$str String the text string to convert
$protect_all Bool Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo;
Returns String XML-converted string

Takes a string as input and converts the following reserved XML characters to entities:

This function ignores ampersands if they are part of existing numbered character entities, e.g. {. Example:

$string = '<p>Here is a paragraph & an entity (&#123;).</p>';
$string = xml_convert($string);
echo $string;

outputs:

&lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;