As far as I know, AgilityPack does not have a direct method for installing doctype, but as Hans mentioned, HAP treats doctype as a node comment. Thus, you can first try to find an existing doctype, if not create a new one, and insert the desired value there:
var doctype = doc.DocumentNode.SelectSingleNode("/comment()[starts-with(.,'<!DOCTYPE')]"); if (doctype == null) doctype = doc.DocumentNode.PrependChild(doc.CreateComment()); doctype.InnerHtml = "<!DOCTYPE html>";
source share