- htmlentities: documentation ( source)
<?php
$xml_header = "<?xml version='1.0' encoding='utf-8'?><xml/>";
$xml = new SimpleXMLElement($xml_header);
$xml->addChild("first_string");
$xml->first_string = "this is &lt;mystring> &euro; &gt; $";
$xml->addChild("first_string2");
$xml->first_string2 = "this is <mystring> € > $";
$xml->addChild("second_string");
$xml->second_string = htmlentities("this is <mystring> € > $");
echo $xml->first_string . "\n";
echo $xml->first_string2 . "\n";
echo $xml->second_string;