Serialising an HTML DOM to string as per the specification