/// <summary> /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode and element context /// </summary> /// /// <param name="target"> /// The target. /// </param> /// <param name="html"> /// The HTML. /// </param> /// <param name="context"> /// The context (e.g. an HTML tag name) /// </param> /// <param name="docType"> /// (optional) type of the document. /// </param> protected void CreateNewFragment(CQ target, string html, string context, DocType docType) { target.Document = DomDocHelper.CreateDocFragment(html, context, docType); // enumerate ChildNodes when creating a new fragment to be sure the selection set only // reflects the original document. target.SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending); }
/// <summary> /// Bind this instance to a new DomFragment created from HTML in a specific HTML tag context. /// </summary> /// /// <param name="target"> /// The target. /// </param> /// <param name="html"> /// The HTML. /// </param> /// <param name="encoding"> /// The character set encoding. /// </param> /// <param name="parsingMode"> /// The HTML parsing mode. /// </param> /// <param name="parsingOptions"> /// (optional) options for controlling the parsing. /// </param> /// <param name="docType"> /// (optional) type of the document. /// </param> protected void CreateNew(CQ target, Stream html, Encoding encoding, HtmlParsingMode parsingMode, HtmlParsingOptions parsingOptions, DocType docType) { target.Document = DomDocHelper.Create(html, encoding, parsingMode, parsingOptions, docType); // enumerate ChildNodes when creating a new fragment to be sure the selection set only // reflects the original document. target.SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending); }