Function to use with SimpleXML that allows you to properly encode all XML values, use in an example like $setting->addChild( $name, xml_entities($v) );
<?php
//for use with SimpleXML objects
//ie $setting->addChild( $name, xml_entities($v) );
if(!function_exists('xml_entities')) {
function xml_entities( $string ) {
return strtr(
$string,
array(
"<" => "<",
">" => ">",
'"' => """,
"'" => "'",
"&" => "&",
)
);
}
}