Example #1
0
        /// <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();
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        /// <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();
        }
Example #5
0
        /// <summary>
        /// Bind this instance to a new empty DomFragment configured with the default options.
        /// </summary>

        protected void CreateNewFragment()
        {
            Document = new DomFragment();
            FinishCreatingNewDocument();
        }
Example #6
0
        /// <summary>
        /// Bind this instance to a new empty DomFragment configured with the default options.
        /// </summary>

        protected void CreateNewFragment()
        {
            Document = new DomFragment();
        }