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


C# HtmlNode.RemoveAllChildren方法代码示例

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


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

示例1: GetStrippedForm

 HtmlNode GetStrippedForm(HtmlNode OriginalForm, List<string> InputElementStrings)
 {
     OriginalForm.RemoveAllChildren();
     foreach (string InputElementString in InputElementStrings)
     {
         HTML InputHtml = new HTML(InputElementString);
         OriginalForm.AppendChild(InputHtml.Html.DocumentNode.FirstChild);
     }
     return OriginalForm;
 }
开发者ID:kartikeyap,项目名称:IronWASP,代码行数:10,代码来源:HTML.cs

示例2: ReplaceAllChildren

        /// <summary>
        /// Replaces all child nodes with the supplied nodes and indents them +1 tab.
        /// </summary>
        private void ReplaceAllChildren(HtmlNode parent, IEnumerable<HtmlNode> nodes)
        {
            // Preserve the indentation of the parent.
            var parentScope = CreateTextNode();
            var prev = parent.PreviousSibling;
            if (prev == null && parent.ParentNode != null)
                prev = parent.ParentNode.PreviousSibling;
            if (prev != null && prev.NodeType == HtmlNodeType.Text)
            {
                var m = TabsAndSpaces.Match(prev.InnerText);
                if (m.Success)
                    parentScope.InnerHtml += m.Value;
            }

            // Add one tab of indentation for the children.
            var childScope = CreateTextNode(parentScope.InnerText + "\t");

            // Replace all children with supplied nodes (indented).
            parent.RemoveAllChildren();
            foreach (var option in nodes)
            {
                parent.AppendChild(childScope);
                parent.AppendChild(option);
            }

            // Put the closing tag at the same indentation as the opening tag.
            parent.AppendChild(parentScope);
        }
开发者ID:jedmao,项目名称:knockout-viewengine,代码行数:31,代码来源:BoundView.cs

示例3: FindTimetableRecursive

        private HtmlNode FindTimetableRecursive(HtmlNode node, TextWriter outText)
        {
            if (HtmlNodeType.Element.Equals(node.NodeType))
              {
            switch (node.Name)
            {
              case "table":
            if (mTitleFound)
            {
              foreach (HtmlAttribute attribute in node.Attributes.AttributesWithName("class"))
              {
                if (CLASS_TIMETABLE.Equals(attribute.Value))
                {
                  outText.WriteLine("Found timetable!");
                  return node;
                }
              }
            }
            break;

              case "td":
            foreach (HtmlAttribute attribute in node.Attributes.AttributesWithName("class"))
            {
              if (CLASS_TITLE.Equals(attribute.Value))
              {
                switch (node.InnerText)
                {
                  case TITLE_WEEKDAYS:
                  case TITLE_SATURDAY:
                  case TITLE_SUNDAY:
                    outText.WriteLine("Found " + node.InnerText + "!");
                    mWeekday = GetWeekdayEnum(node.InnerText);
                    mTitleFound = true;
                    break;
                }
              }
            }
            break;

              default:
            break;
            }
              }

              foreach (HtmlNode subnode in node.ChildNodes)
              {
            HtmlNode tableNode = FindTimetableRecursive(subnode, outText);
            if (tableNode != null)
            {
              return tableNode;
            }
              }

              node.RemoveAllChildren();
              return null;
        }
开发者ID:peruukki,项目名称:StopWatch,代码行数:56,代码来源:StopTimeParser.cs

示例4: TryGetNode

        /// <summary>
        /// Tries to get the node.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="node">The node.</param>
        /// <returns>A boolean value.</returns>
        private bool TryGetNode(int index, out HtmlNode node)
        {
            var n = XpathUtil.GetNode(_html, string.Format("//*[@diffengineindexer='{0}']", index));
            node = null;

            if (n != null)
            {
                // Create a deep copy of the html
                node = n.CloneNode(true);

                // Remove the attribute set by the scraper (used for indexing)
                node.Attributes.Remove("diffengineindexer");

                // Discard child elements
                node.RemoveAllChildren();
            }

            return node != null;
        }
开发者ID:Ancestry,项目名称:quality-bot,代码行数:25,代码来源:ElementProvider.cs

示例5: filterElement

 /// <summary>
 /// Filters the element, returns whether the element was removed.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 private bool filterElement(HtmlNode node)
 {
     if (ElementFilter.IsValid(node))
     {
         for(int i = 0; i < node.ChildNodes.Count; i++)
         {
             if (filterElement(node.ChildNodes[i]))
             {
                 i--;
             }
         }
         return false;
     }
     else
     {
         node.RemoveAllChildren();
         node.Remove();
         return true;
     }
 }
开发者ID:KallynGowdy,项目名称:TheFlow,代码行数:25,代码来源:Sanitizer.cs


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