We've had issues in the past encoding strings with htmlspecialchars() for inserting into XML, since some entities may be encoded with names that the XML parser doesn't recognize, but I can't recall any specific details now ;) It's a shame there isn't an xmlspecialchars() function that is for strict XML, not HTML. Given that I can't recall the details, I'll just leave this for now, but there's definitely an issue using it with XML ;)