The little known PHP htmlspecialchars
Posted on February 20th, 2010 by Paul
Want to replace only xml entities <, >, &? Don’t use htmlentites or str_replace; use htmlspecialchars.
The only named entities for XML are &, > and <. For all others you need to use the Unicode character code (eg.  ).
Webkit: Entity ‘nbsp’ not defined – Convert HTML entities to XML
