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


C# HtmlNode.Element方法代码示例

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


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

示例1: IsUnwantedLanguageDiv

 private static bool IsUnwantedLanguageDiv(HtmlNode div)
 {
     return div.GetAttributeValue("class", "").Equals("libCScode")
            &&
            !div.Element("div").Element("div").InnerText.Trim().Equals("c#",
                                                                       StringComparison.CurrentCultureIgnoreCase);
 }
开发者ID:markrendle,项目名称:PocketIDE,代码行数:7,代码来源:ContentProcessor.cs

示例2: ProcessElem

        private void ProcessElem(HtmlNode liElem, List<SongInRankingContract> songs)
        {
            var spanElem = liElem.Element("span");

            if (spanElem == null)
                return;

            var strongElem = spanElem.SelectSingleNode("strong");

            if (strongElem == null)
                return;	// List has items without order number (like "ED song") - skip them

            var orderNumStr = strongElem.InnerText;
            var numPart = numRegex.Match(orderNumStr);
            var orderNum = int.Parse(numPart.Value);

            var aElem = liElem.Element("a");
            var nicoUrl = aElem.Attributes["href"].Value;
            var nicoId = GetNicoId(nicoUrl);

            var name = aElem.InnerText;

            songs.Add(new SongInRankingContract { Name = name, NicoId = nicoId, SortIndex = orderNum });

            foreach (var childElem in liElem.ChildNodes)
                ProcessElem(childElem, songs);
        }
开发者ID:realzhaorong,项目名称:vocadb,代码行数:27,代码来源:VocaloidismWVRParser.cs

示例3: ApplyComment

 private static void ApplyComment(HtmlNode dayNoteDiv, DayNote dayNote)
 {
     var commentNode = dayNoteDiv.Element("span");
     dayNote.Comment = commentNode != null
         ? HttpUtility.HtmlDecode(commentNode.InnerText)
         : null;
 }
开发者ID:wezzix,项目名称:funbeat-downloader,代码行数:7,代码来源:DayNoteParser.cs

示例4: MsdnIssue

        public MsdnIssue(int year, HtmlNode tableCellCover)
        {
            var cellInfos = tableCellCover.NextSibling;

            Year = year;
            Title = cellInfos.Element("strong").InnerText;
            CoverImageUrl = new Uri(tableCellCover.Descendants("img").First().GetAttributeValue("src", ""));
            _url = new Uri(tableCellCover.Element("a").GetAttributeValue("href", ""));
        }
开发者ID:mareek,项目名称:WebAdHocCrawler,代码行数:9,代码来源:MsdnIssue.cs

示例5: GameFromDiv

        public static SteamGame GameFromDiv(HtmlNode divElement)
        {
            var gamePageLink = divElement.Element("a");
            var title = gamePageLink.GetAttributeValue("title", "Error");
            var url = gamePageLink.GetAttributeValue("href", "Error");

            var priceDiv = divElement.Descendants("div").Where(d => d.GetAttributeValue("class", "") == "price").First();
            var normalPriceSpan = priceDiv.Descendants("span").Where(s => s.GetAttributeValue("class", "") == "was").First();
            var salePriceSpan = priceDiv.Descendants("span").Where(s => s.GetAttributeValue("class", "") == "").First();

            var normalPrice = ParsePrice(normalPriceSpan);
            var salePrice = ParsePrice(salePriceSpan);

            return new SteamGame(title, url, normalPrice, salePrice);
        }
开发者ID:mareek,项目名称:WebAdHocCrawler,代码行数:15,代码来源:SteamHelper.cs

示例6: FindTracklistRow

		private HtmlNode FindTracklistRow(HtmlDocument doc, HtmlNode row) {

			// Find the first table row on the page
			if (row == null)
				row = doc.DocumentNode.SelectSingleNode(".//div[@class='postcontent']/table/tr[1]");

			if (row != null) {

				while (row != null) {

					var cell = row.Element("td");

					if (cell != null && ContainsTracklist(cell))
						return row;

					row = row.NextSibling;

				}

			} else {

				// Legacy pages don't have a <table>, but <p> elements instead
				row = doc.DocumentNode.SelectSingleNode(".//div[@class='postcontent']/p[2]");

				while (row != null) {

					if (ContainsTracklist(row))
						return row;

					row = row.NextSibling;

				}

			}

			return null;

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:38,代码来源:MikuDbAlbumImporter.cs

示例7: ParseVolumeSection

        static Volume ParseVolumeSection(HtmlNode section)
        {
            Volume volume = new Volume();
            volume.CoverImageUri = section.FirstChildClass("cover").Element("img").GetAttributeValue("src", string.Empty);
            volume.Title = WebUtility.HtmlDecode(section.FirstChildClass("info").InnerText);
            volume.Label = ExtractLabel(volume.Title);
            volume.Title = RemoveLabel(volume.Title);
            volume.Chapters = section.Element("ul").Elements("li").Select(li =>
            {
                var cpt = new ChapterProperties();
                var a = li.Element("a");
                var pos = ParseIDFromReadLink(a.GetAttributeValue("href", String.Empty));
                cpt.Id = pos.ChapterId;
                cpt.ParentVolumeId = pos.VolumeId;
                cpt.ParentSeriesId = pos.SeriesId;
                cpt.Title = a.InnerText;
                return cpt;
            }).ToList();

            if (volume.Chapters.Count > 0)
            {
                volume.Id = volume.Chapters[0].ParentVolumeId;
                volume.ParentSeriesId = volume.Chapters[0].ParentSeriesId;
            }

            for (int chapterIdx = 0; chapterIdx < volume.Chapters.Count; chapterIdx++)
            {
                var chapter = volume.Chapters[chapterIdx];
                chapter.ChapterNo = chapterIdx;
                //chapter.ParentVolumeId = vol.Id;
                chapter.ParentVolumeId = volume.Id;
                if (chapterIdx > 0)
                {
                    //chapter.PrevChapter = vol.Chapters[chapterIdx - 1];
                    chapter.PrevChapterId = volume.Chapters[chapterIdx - 1].Id;
                }
                if (chapterIdx < volume.Chapters.Count - 1)
                {
                    //chapter.NextChapter = vol.Chapters[chapterIdx + 1];
                    chapter.NextChapterId = volume.Chapters[chapterIdx + 1].Id;
                }
            }
            return volume;
        }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:44,代码来源:LightKindomHtmlClient.cs

示例8: ParseBookItem

        // a href = "/book/detail?id=*"
        private static BookItem ParseBookItem(HtmlNode a)
        {
            var book = new BookItem();
            book.HyperLinkUri = a.GetAttributeValue("href", null);
            book.CoverImageUri = a.Element("img")?.GetAttributeValue("src", null);
            book.Title = a.FirstChildClass("title")?.InnerText;

            if (book.Title == null)
                book.Title = CleanText(a.InnerText);

            book.Subtitle = a.FirstChildClass("status")?.InnerText;
            book.SeriesId = ParseIDFromBookLink(book.HyperLinkUri);
            return book;
        }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:15,代码来源:LightKindomHtmlClient.cs

示例9: ClearNodes

        private static HtmlNode ClearNodes(HtmlNode JobOfferElement)
        {
            //var trsToRemove = JobOfferElement.Elements("tr").ToList();

            //JobOfferElement.RemoveChild(trsToRemove[0]);
            //JobOfferElement.RemoveChild(trsToRemove[1]);
            //JobOfferElement.RemoveChild(trsToRemove[2]);

            JobOfferElement = RemoveDescendants(JobOfferElement, new string[] { "a", "img", "script", "style" });
            JobOfferElement.RemoveChild(JobOfferElement.Element("tr"));

            var trS = JobOfferElement.Elements("tr").ToList();

            bool removeNext = false;
            foreach (var item in trS)
            {
                if (removeNext == false)
                {
                    if (item.Descendants().Where(
                        d => (d.Attributes.Contains("class") &&
                            d.Attributes["class"].Value.Contains("button_new"))
                            ).Count() > 0)
                    {
                        removeNext = true;
                    }
                }
                if (removeNext == true)
                {
                    JobOfferElement.RemoveChild(item);
                }
            }

            return JobOfferElement;
        }
开发者ID:kirotab,项目名称:JobsMatch,代码行数:34,代码来源:RemoteDataManager.cs

示例10: PopulateTeam

        public void PopulateTeam(HtmlNode table, ref List<Cast> castList, string roleName)
        {
            var tbody = table.Element("tbody");

            if (tbody != null)
            {
                var tr = tbody.Elements("tr");
                if (tr != null)
                {
                    foreach (HtmlNode row in tr)
                    {
                        var nameNodes = row.Elements("td");
                        if (nameNodes != null)
                        {
                            Cast cast = new Cast();
                            cast.role = roleName.Replace("&nbsp;", " ");

                            foreach (HtmlNode node in nameNodes)
                            {
                                if (node.Attributes["class"] != null && node.Attributes["class"].Value == "name")
                                {
                                    var link = node.Element("a");
                                    cast.name = link.InnerText.Replace("'", string.Empty).Replace("&", string.Empty).Trim();

                                    if (link.Attributes["href"] != null)
                                    {
                                        cast.link = link.Attributes["href"].Value;
                                    }
                                }
                                else if (node.Attributes["class"] != null && node.Attributes["class"].Value == "credit")
                                {
                                    cast.charactername = node.InnerText.Replace("'", string.Empty).Replace("&", string.Empty).Trim();
                                }
                            }

                            castList.Add(cast);
                        }
                    }
                }
            }
        }
开发者ID:viren85,项目名称:moviemirchi,代码行数:41,代码来源:ImdbCrawler.cs

示例11: getVideoInfo

        private VideoInfo getVideoInfo(HtmlNode itemDiv)
        {
            VideoInfo video = new VideoInfo();

            video.VideoUrl = itemDiv.Elements("div").Last().GetAttributeValue("arte_vp_url", "");
            video.Length = itemDiv.Descendants("div").Where(d => d.GetAttributeValue("class", "").Contains("badge-holder")).FirstOrDefault().Element("div").NextSibling.InnerText.Trim().Trim('"').Trim();
            video.Airdate = itemDiv.Descendants("p").FirstOrDefault().ChildNodes.LastOrDefault().InnerText.Trim();
            video.Title = itemDiv.Descendants("h3").FirstOrDefault().InnerText.Trim();
            video.Thumb = itemDiv.Element("img").GetAttributeValue("src", "");
            video.Description = itemDiv.GetAttributeValue("data-description", "");

            return video;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:13,代码来源:ArtePlus7Util.cs

示例12: ExtractPayload

 private static Tuple<HtmlNode, HtmlNode> ExtractPayload(HtmlNode tableNode, int titleIndex, int ratingIndex)
 {
     var row = tableNode.Element("tr");
     if (row == null)
         return null;
     var cells = row.Elements("td").ToList();
     if (cells.Count < 2)
         return null;
     var linkNode = cells[titleIndex].ChildNodes.FirstOrDefault(n => n.Name == "a");
     if (linkNode == null)
         return null;
     var linkNodeClass = linkNode.Attributes["class"];
     if (linkNodeClass == null || linkNodeClass.Value != "animetitle")
         return null;
     return Tuple.Create(linkNode, cells[ratingIndex]);
 }
开发者ID:vosen,项目名称:Juiz.Shared,代码行数:16,代码来源:Extract.cs


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