refactoring xhtml serializer

@fosdev please review PR request and merge