Add serialization function to HtmlDocument.