I have searched stackoverflow on this problem and did find a few topics, but I feel like there isn\'t really a solid answer for me on this.
I have a form that users
I agree that it is purely an encoding issue. In PHP, this is how I solved this problem:
Before passing the html-fragment to SimpleXMLElement constructor I decoded it by using html_entity_decode.
Then further encoded it using utf8_encode().
$headerDoc = '' . utf8_encode(html_entity_decode($headerFragment)) . ' ';
$xmlHeader = new SimpleXMLElement($headerDoc);
Now the above code does not throw any undefined entity errors.