src/XML/Util.php
function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
        $encoding = 'ISO-8859-1')
    {
        switch ($replaceEntities) {
        case XML_UTIL_ENTITIES_XML:
            return strtr($string, array(
                '&amp;'  => '&',
                '&gt;'   => '>',
                '&lt;'   => '<',
                '&quot;' => '"',
                '&apos;' => '\'' ));
            break;
        case XML_UTIL_ENTITIES_XML_REQUIRED:
            return strtr($string, array(
                '&amp;'  => '&',
                '&lt;'   => '<',
                '&quot;' => '"' ));
            break;
        case XML_UTIL_ENTITIES_HTML:
            return html_entity_decode($string, ENT_COMPAT, $encoding);
            break;
        }
        return $string;
    }
function reverseEntities($string, $replaceEntities = XML_UTIL_ENTITIES_XML,
        $encoding = 'ISO-8859-1')
    {
        switch ($replaceEntities) {
        case XML_UTIL_ENTITIES_XML:
            return strtr($string, array(
                '&amp;'  => '&',
                '&gt;'   => '>',
                '&lt;'   => '<',
                '&quot;' => '"',
                '&apos;' => '\'' ));
            break;
        case XML_UTIL_ENTITIES_XML_REQUIRED:
            return strtr($string, array(
                '&amp;'  => '&',
                '&lt;'   => '<',
                '&quot;' => '"' ));
            break;
        case XML_UTIL_ENTITIES_HTML:
            return html_entity_decode($string, ENT_COMPAT, $encoding);
            break;
        }
        return $string;
    }
reverse XML entities

With the optional second parameter, you may select, which
entities should be reversed.

<code>
require_once 'XML/Util.php';

// reverse XML entites:
$string = XML_Util::reverseEntities('This string contains &lt; &amp; &gt;.');
</code>

With the optional third parameter, you may pass the character encoding
<code>
require_once 'XML/Util.php';

// reverse XML entites in UTF-8:
$string = XML_Util::reverseEntities(
'This string contains &lt; &amp; &gt; as well as'
. ' &auml;, &ouml;, &szlig;, &agrave; and &ecirc;',
XML_UTIL_ENTITIES_HTML,
'UTF-8'
);
</code>

@param string $string          string where XML special chars
should be replaced
@param int    $replaceEntities setting for entities in attribute values
(one of XML_UTIL_ENTITIES_XML,
XML_UTIL_ENTITIES_XML_REQUIRED,
XML_UTIL_ENTITIES_HTML)
@param string $encoding        encoding value (if any)...
must be a valid encoding as determined
by the html_entity_decode() function

@return string string with replaced chars
@access public
@static
@see replaceEntities()