/// <summary> /// Bind this instance to a new DomFragment created from HTML using the specified parsing mode. /// </summary> /// /// <param name="html"> /// The HTML. /// </param> /// <param name="htmlParsingMode"> /// The HTML parsing mode. /// </param> protected void CreateNewFragment(char[] html, HtmlParsingMode htmlParsingMode) { Document = new DomFragment(html, htmlParsingMode); // enumerate ChildNodes when creating a new fragment to be sure the selection set only // reflects the original document. SetSelection(Document.ChildNodes.ToList(), SelectionSetOrder.Ascending); FinishCreatingNewDocument(); }
/// <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 = DomFragment.Create(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); }
public void CheckFragmentIndex() { var frag = TestFragment(); DomFragment concreteFrag = (DomFragment)frag[0].Document; Assert.IsTrue(concreteFrag.IsFragment); Assert.IsTrue(concreteFrag.IsIndexed); var index = concreteFrag.DocumentIndex; if (index is IDomIndexSimple) { Assert.AreNotEqual(0, index.Count); } else { Assert.AreEqual(0, index.Count); } }
/// <summary> /// Bind this instance to a new DomFragment created from a sequence of elements. /// </summary> /// /// <param name="elements"> /// The elements to provide the source for this object's DOM. /// </param> protected void CreateNewFragment(IEnumerable <IDomObject> elements) { Document = new DomFragment(elements.Clone()); AddSelection(Document.ChildNodes); FinishCreatingNewDocument(); }
/// <summary> /// Bind this instance to a new empty DomFragment configured with the default options. /// </summary> protected void CreateNewFragment() { Document = new DomFragment(); FinishCreatingNewDocument(); }
/// <summary> /// Bind this instance to a new empty DomFragment configured with the default options. /// </summary> protected void CreateNewFragment() { Document = new DomFragment(); }