FIX issues in XHTML5 rendering mode

The two commits below fix issues with DOM manipulation when rendering the page as XHTML5 (id est HTML5 with Content-Type=application/xhtml+xml)
In this mode, attribute must have a value and &nbsp; is not a valid entity.

Tested with Chrome.