Changed so that we covert the html of the root element rather than the children. The problem was that we where loosing whitespaces do to them not being returned as children.
new version