Improved workaround for buggy libxml/DOM behavior with namespaced attributes in HTML parsing mode, closes #575 and fixes #574