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


C# HtmlNode.GetElementsOfType方法代码示例

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


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

示例1: GetFacets

 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var elements = document.GetElementsOfType("h1");
     if (elements.Count() > 1)
         yield return
             GetFacet("Document contains multiple H1 tags", SEOAnalysisStatus.Error,
                 "There should only be one H1 tag in a document.");
 }
开发者ID:neozhu,项目名称:MrCMS,代码行数:8,代码来源:SingleH1Tag.cs

示例2: GetFacets

        public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
        {
            var images = document.GetElementsOfType("img").ToList();

            IEnumerable<HtmlNode> imagesWithoutAlt = images.FindAll(node => !node.Attributes.Contains("alt"));

            string hasNotGotAnAltTag = _stringResourceProvider.GetValue("Admin SEO Analysis Has not got", " has not got an alt tag");
            yield return GetFacet(_stringResourceProvider.GetValue("Admin SEO Analysis Has not got alt tags", "All images have alt tags"),
                !imagesWithoutAlt.Any()
                    ? SEOAnalysisStatus.Success
                    : SEOAnalysisStatus.Error,
                imagesWithoutAlt.Select(node => node.GetAttributeValue("src", "") + hasNotGotAnAltTag).ToArray());
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:13,代码来源:AllImagesHaveAltTags.cs

示例3: GetFacets

 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var subheadings = document.GetElementsOfType("h2").ToList();
     if (!subheadings.Any())
     {
         yield return GetFacet("Subheadings", SEOAnalysisStatus.CanBeImproved, "The page contains no subheadings (i.e. h2 tags)");
         yield break;
     }
     var matchingNodes = subheadings.FindAll(node => node.InnerHtml.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase));
     if (!matchingNodes.Any())
         yield return
             GetFacet("Subheadings", SEOAnalysisStatus.CanBeImproved, string.Format("{0} of the {1} subheadings contain the target term", matchingNodes.Count(), subheadings.Count()));
     else
         yield return
             GetFacet("Subheadings", SEOAnalysisStatus.Success, string.Format("{0} of the {1} subheadings contain the target term", matchingNodes.Count(), subheadings.Count()));
 }
开发者ID:neozhu,项目名称:MrCMS,代码行数:16,代码来源:SubheadingsContainingTerm.cs

示例4: GetFacets

 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var paragraphs = document.GetElementsOfType("p").ToList();
     if (!paragraphs.Any())
     {
         yield return
             GetFacet("Body Content", SEOAnalysisStatus.Error,
                 string.Format("Body content contains no paragraphs of text"));
         yield break;
     }
     if (paragraphs[0].InnerText.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
     {
         yield return GetFacet("Body Content", SEOAnalysisStatus.Success,
             string.Format("The first paragraph contains the term '{0}'", analysisTerm));
     }
     else
     {
         yield return GetFacet("Body Content", SEOAnalysisStatus.CanBeImproved,
             string.Format("The first paragraph does not contain the term '{0}'", analysisTerm));
     }
 }
开发者ID:neozhu,项目名称:MrCMS,代码行数:21,代码来源:BodyContentFirstParagraphContainsTerm.cs


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