当前位置: 首页>>代码示例>>C#>>正文


C# HtmlNode.CloneNode方法代码示例

本文整理汇总了C#中HtmlAgilityPack.HtmlNode.CloneNode方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.CloneNode方法的具体用法?C# HtmlNode.CloneNode怎么用?C# HtmlNode.CloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack.HtmlNode的用法示例。


在下文中一共展示了HtmlNode.CloneNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Entitize

        /// <summary>
        /// Clone and entitize an HtmlNode. This will affect attribute values and nodes' text. It will also entitize all child nodes.
        /// </summary>
        /// <param name="node">The node to entitize.</param>
        /// <returns>An entitized cloned node.</returns>
        public static HtmlNode Entitize(HtmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            HtmlNode result = node.CloneNode(true);
            if (result.HasAttributes)
                Entitize(result.Attributes);

            if (result.HasChildNodes)
            {
                Entitize(result.ChildNodes);
            }
            else
            {
                if (result.NodeType == HtmlNodeType.Text)
                {
                    ((HtmlTextNode) result).Text = Entitize(((HtmlTextNode) result).Text, true, true);
                }
            }
            return result;
        }
开发者ID:REALTOBIZ,项目名称:mono,代码行数:28,代码来源:HtmlEntity.cs

示例2: Entitize

 /// <summary>
 /// Clone and entitize an HtmlNode. This will affect attribute values and nodes' text. It will also entitize all child nodes.
 /// 
 /// </summary>
 /// <param name="node">The node to entitize.</param>
 /// <returns>
 /// An entitized cloned node.
 /// </returns>
 public static HtmlNode Entitize(HtmlNode node)
 {
   if (node == null)
     throw new ArgumentNullException("node");
   HtmlNode htmlNode = node.CloneNode(true);
   if (htmlNode.HasAttributes)
     HtmlEntity.Entitize(htmlNode.Attributes);
   if (htmlNode.HasChildNodes)
     HtmlEntity.Entitize(htmlNode.ChildNodes);
   else if (htmlNode.NodeType == HtmlNodeType.Text)
     ((HtmlTextNode) htmlNode).Text = HtmlEntity.Entitize(((HtmlTextNode) htmlNode).Text, true, true);
   return htmlNode;
 }
开发者ID:kirillbeldyaga,项目名称:web_browser,代码行数:21,代码来源:HtmlEntity.cs

示例3: GetNodeIndex

 /// <summary>
 /// Gets a given node from the list.
 /// </summary>
 public int this[HtmlNode node]
 {
     get
     {
         int index = GetNodeIndex(node);
         if (index == -1)
         {
             throw new ArgumentOutOfRangeException("node", "Node \"" + node.CloneNode(false).OuterHtml + "\" was not found in the collection");
         }
         return index;
     }
 }
开发者ID:GitHubXur,项目名称:Fine-UI,代码行数:15,代码来源:HtmlNodeCollection.cs

示例4: SectionizeNodes

        /**********************************************************************/
        private void SectionizeNodes(HtmlNode node, ref List<DocumentSection> documentSections)
        {
            foreach (HtmlAttribute hat in node.Attributes)
            {
                if (hat.Name == "id" && !string.IsNullOrEmpty(hat.Value))
                {
                    DocumentSection ds = new DocumentSection();
                    ds.SectionNode = node.CloneNode(true);
                    ;
                    ds.title = hat.Value;
                    documentSections.Add(ds);
                }
            }

            foreach (HtmlNode child in node.ChildNodes)
            {
                SectionizeNodes(child, ref documentSections);
            }
        }
开发者ID:mahitosh,项目名称:HRA4,代码行数:20,代码来源:Sectionizer.cs


注:本文中的HtmlAgilityPack.HtmlNode.CloneNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。