public void DocumentParsingEventHandler(object sender, DocumentParsingEventArgs e) { XElement html = e.Document.Root; XElement head = html.Element("head"); Check.NotNull(head, "<head> section is missing from document"); XElement style = new XElement("style"); style.SetValue(StylesheetContent); head.AddFirst(style); }
public void DocumentParsingEventHandler(object sender, DocumentParsingEventArgs e) { XElement html = e.Document.Root; Check.IsTrue("html".Equals(html.Name.LocalName), "Only <html> documents are supported (<" + html.Name.LocalName + "> is not)"); if (!HasHeadSection(html)) { XElement head = new XElement("head"); CopyNodesBeforeBodyIntoHead(html, head); html.AddFirst(head); } }