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


C# HtmlNodeCollection.Add方法代码示例

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


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

示例1: run

        /// <summary>
        /// Run xpath from html or node
        /// </summary>
        public List<List<KeyValuePair<string, object>>> run(HtmlNode node)
        {
            Factory.Instance.iInfo(string.Format("Running xpathCollection id : {0}", rule.id));

            HtmlNodeCollection nodes = new HtmlNodeCollection(node);
            HtmlNodeCollection n2 = node.SelectNodes(rule.xpath);
            if (n2 != null)
            {
                foreach (HtmlNode n in n2)
                    nodes.Add(n);
            }

            //run
            if (node != null)
            {

                foreach (HtmlNode n in nodes)
                {
                    List<KeyValuePair<string, object>> last_val = null;
                    if (rule.xpathSingle != null)
                    {
                        XPathSingle xs = new XPathSingle(rule.xpathSingle, last_val);
                        last_val = (List<KeyValuePair<string, object>>)xs.Run(n);
                        res.Add(last_val);
                    }
                }
            }
            return res;
        }
开发者ID:kantone,项目名称:intelliscraper,代码行数:32,代码来源:XPathCollection.cs

示例2: SelectNodes

        /// <summary>
        /// Selects a list of nodes matching the <see cref="XPath"/> expression.
        /// </summary>
        /// <param name="xpath">The XPath expression.</param>
        /// <returns>An <see cref="HtmlNodeCollection"/> containing a collection of nodes matching the <see cref="XPath"/> query, or <c>null</c> if no node matched the XPath expression.</returns>
        public HtmlNodeCollection SelectNodes(string xpath)
        {
            var list = new HtmlNodeCollection(null);

            var nav = new HtmlNodeNavigator(OwnerDocument, this);
            var it = nav.Select(xpath);
            while (it.MoveNext())
            {
                var n = (HtmlNodeNavigator)it.Current;
                list.Add(n.CurrentNode);
            }
            return list.Count == 0 ? null : list;
        }
开发者ID:matsprea,项目名称:HtmlAgilityPack-DNX,代码行数:18,代码来源:HtmlNode.Xpath.cs

示例3: SelectNodes

        /// <summary>
        /// Selects a list of nodes matching the <see cref="XPath"/> expression.
        /// </summary>
        /// <param name="xpath">The XPath expression.</param>
        /// <returns>An <see cref="HtmlNodeCollection"/> containing a collection of nodes matching the <see cref="XPath"/> query, or <c>null</c> if no node matched the XPath expression.</returns>
        public HtmlNodeCollection SelectNodes(string xpath)
        {
            HtmlNodeCollection list = new HtmlNodeCollection(null);
            HtmlNodeNavigator nav = new HtmlNodeNavigator(OwnerDocument, this);

            XPathNodeIterator it = nav.Select(xpath);
            while (it.MoveNext())
            {
                HtmlNodeNavigator n = (HtmlNodeNavigator)it.Current;
                list.Add(n.CurrentNode);
            }

            return list;
        }
开发者ID:moby41,项目名称:HtmlAgilityPack,代码行数:19,代码来源:HtmlNode.Xpath.cs

示例4: GetLinksReturnsCorrectValue

        public void GetLinksReturnsCorrectValue()
        {
            // check that there is no exception and it returns empty list
            Assert.Equal(0, GetLinks(null).Count);

            // check with the predefined html
            HtmlDocument doc = new HtmlDocument();
            Page page = PageDocumentTestHelper.GetTestPage(3);
            doc.LoadHtml(page.Content);
            HtmlNodeCollection col = new HtmlNodeCollection(doc.DocumentNode);
            foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
                col.Add(link);
            Assert.Equal(129, GetLinks(col).Count);
        }
开发者ID:Insvald,项目名称:Taygeta,代码行数:14,代码来源:PreciseHyperLinkParserTest.cs

示例5: GoToPageAndGetTableNodes

        private void GoToPageAndGetTableNodes(string startUrl, string pageUrl, HtmlNodeCollection allTableNodesForMonth)
        {
            string url = startUrl + pageUrl;
            bool haveNextPage = true;
            do
            {
                // Get all links for the first page
                HtmlWeb web = new HtmlWeb();
                HtmlDocument doc = web.Load(url);
                HtmlNodeCollection tableNodes = doc.DocumentNode.SelectNodes("//tr[@class='roweven']|//tr[@class='rowodd']");
                foreach (var node in tableNodes)
                {
                    allTableNodesForMonth.Add(node);
                }

                // Get links for the other pages
                HtmlNode nextPage = null;
                if (doc.DocumentNode.SelectNodes("//td[@class='pagenumber']") != null)
                {
                    nextPage = doc.DocumentNode.SelectNodes("//td[@class='pagenumber']").LastOrDefault();
                }

                if (nextPage != null)
                {
                    var linkNode = nextPage.FirstChild;
                    if (linkNode.Attributes["href"] != null)
                    {
                        url = startUrl + "/cgi-bin/rechtsprechung/" + linkNode.Attributes["href"].Value;
                        url = url.Replace("amp;", string.Empty);
                    }
                    else
                    {
                        haveNextPage = false;
                    }
                }
                else
                {
                    haveNextPage = false;
                }
            }
            while (haveNextPage);
        }
开发者ID:apis-bulgaria,项目名称:EUCases.Crawlers,代码行数:42,代码来源:BundesCommon.cs

示例6: SelectNodes

		/// <summary>
		/// Selects a list of nodes matching the XPath expression.
		/// </summary>
		/// <param name="xpath">The XPath expression.</param>
		/// <returns>An HtmlNodeCollection containing a collection of nodes matching the XPath query, or null if no node matched the XPath expression.</returns>
		public HtmlNodeCollection SelectNodes(string xpath)
		{
			HtmlNodeCollection list = new HtmlNodeCollection(null);
            try
            {
                HtmlNodeNavigator nav = new HtmlNodeNavigator(_ownerdocument, this);
                XPathNodeIterator it = nav.Select(xpath);
                while (it.MoveNext())
                {
                    HtmlNodeNavigator n = (HtmlNodeNavigator)it.Current;
                    list.Add(n.CurrentNode);
                }
            }
            catch (Exception ex)
            {
                O2.Kernel.ExtensionMethods.Logging_ExtensionMethods.log(ex, "in HtmlNodeCollection SelectNodes");
            }
            //DC removed this so that we get an empty list when there are no matching nodes
			//if (list.Count == 0)
			//{
			//	return null;
			//}
			return list;
		}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:29,代码来源:HtmlNode.cs

示例7: get_gallery_items_nodes

 public override HtmlNodeCollection get_gallery_items_nodes(HtmlNode root)
 {
     var node_items = new HtmlNodeCollection (null);
     var items = base.get_gallery_items_nodes (root);
     foreach (var item in items) {
         // skip signatures
         if (item.Attributes.Contains ("class") && item.Attributes ["class"].Value.Contains ("signature")) {
             continue;
         }
         var nodes = item.SelectNodes (".//a");
         if (nodes != null) {
             foreach (var node in nodes) {
                 node_items.Add (node);
             }
         }
     }
     return node_items;
 }
开发者ID:SevenLines,项目名称:csharp-superiorpics,代码行数:18,代码来源:SuperiorpicsSource.cs

示例8: FinalizeHtmlDocument

        private void FinalizeHtmlDocument(IList<ArelleColumnSection> outlist)
        {
            var mtn = this.mainTableNode;
            for (int i = 0; i < mtn.ChildNodes.Count; i++)
            {
                mtn.ChildNodes[i].RemoveAllChildren();
                var row = new HtmlNodeCollection(mtn.ChildNodes[i]);
                foreach (var item in outlist[i].DynamicColumns)
                {
                    row.Add(item);
                }

                foreach (var item in outlist[i].NewStaticColumns)
                {
                    row.Add(item);
                }

                mtn.ChildNodes[i].AppendChildren(row);
            }
        }
开发者ID:plamikcho,项目名称:xbrlpoc,代码行数:20,代码来源:ArelleFactTableHtmlRenderer.cs

示例9: SelectNodes

 /// <summary>
 /// Selects a list of nodes matching the <see cref="P:HtmlAgilityPack.HtmlNode.XPath"/> expression.
 /// 
 /// </summary>
 /// <param name="xpath">The XPath expression.</param>
 /// <returns>
 /// An <see cref="T:HtmlAgilityPack.HtmlNodeCollection"/> containing a collection of nodes matching the <see cref="P:HtmlAgilityPack.HtmlNode.XPath"/> query, or <c>null</c> if no node matched the XPath expression.
 /// </returns>
 public HtmlNodeCollection SelectNodes(string xpath)
 {
   HtmlNodeCollection htmlNodeCollection = new HtmlNodeCollection((HtmlNode) null);
   XPathNodeIterator xpathNodeIterator = new HtmlNodeNavigator(this.OwnerDocument, this).Select(xpath);
   while (xpathNodeIterator.MoveNext())
   {
     HtmlNodeNavigator htmlNodeNavigator = (HtmlNodeNavigator) xpathNodeIterator.Current;
     htmlNodeCollection.Add(htmlNodeNavigator.CurrentNode);
   }
   if (htmlNodeCollection.Count == 0)
     return (HtmlNodeCollection) null;
   return htmlNodeCollection;
 }
开发者ID:kirillbeldyaga,项目名称:web_browser,代码行数:21,代码来源:HtmlNode.cs


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