public static void SetInnerHtml(this XElement element, string html) { if (element == null || html == null) { throw new ArgumentNullException("element" + " | " + "html"); } element.RemoveAll(); var tmpElement = new SgmlDomFactory().BuildDocument(html); if (tmpElement.Root == null) { return; } foreach (var node in tmpElement.Root.Nodes()) { element.Add(node); } }
using System;