CsQuery.CQ.CreateNewFragment C# (CSharp) Метод

CreateNewFragment() защищенный Метод

Bind this instance to a new DomFragment created from HTML using the specified parsing mode and element context
protected CreateNewFragment ( CQ target, string html, string context, DocType docType ) : void
target CQ /// The target. ///
html string /// The HTML. ///
context string /// The context (e.g. an HTML tag name) ///
docType DocType /// (optional) type of the document. ///
Результат void
        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);
        }

Same methods

CQ::CreateNewFragment ( ) : void
CQ::CreateNewFragment ( IEnumerable elements ) : void

Usage Example

Пример #1
0
        /// <summary>
        /// Creeate a new fragment from HTML text, in the context of a specific HTML tag.
        /// </summary>
        ///
        /// <param name="html">
        /// A string of HTML.
        /// </param>
        /// <param name="context">
        /// The HTML tag name which is the context
        /// </param>
        ///
        /// <returns>
        /// The new fragment.
        /// </returns>

        public static CQ CreateFragment(string html, string context)
        {
            CQ cq = new CQ();

            cq.CreateNewFragment(cq, html, context, DocType.Default);
            return(cq);
        }
All Usage Examples Of CsQuery.CQ::CreateNewFragment