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


C# HtmlNode.GetElementText方法代码示例

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


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

示例1: GetFacets

        public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
        {
            string titleText = document.GetElementText("title") ?? string.Empty;

            if (titleText.Length < 50)
                yield return GetFacet("Title length", SEOAnalysisStatus.Error, "The title should be at least 50 characters long");
            else if (titleText.Length > 90)
                yield return
                    GetFacet("Title length", SEOAnalysisStatus.Error, "The title should be at most 90 characters long");
            else
                yield return
                    GetFacet("Title length", SEOAnalysisStatus.Success,
                        "The title is of optimal length (50-90 characters)");
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:14,代码来源:TitleIsCorrectLength.cs

示例2: GetFacets

 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     var element = document.GetElement("h1");
     if (element == null)
     {
         yield return GetFacet("H1 is missing", SEOAnalysisStatus.Error, "The H1 element is missing in the page");
         yield break;
     }
     string h1Text = document.GetElementText("h1");
     if (h1Text.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
         yield return
             GetFacet("H1 contains term", SEOAnalysisStatus.Success,
                 "The H1 element contains '" + analysisTerm + "'");
     else
         yield return
             GetFacet("H1 contains term", SEOAnalysisStatus.Error,
                 "The H1 element does not contain '" + analysisTerm + "'");
 }
开发者ID:neozhu,项目名称:MrCMS,代码行数:18,代码来源:H1ContainsTerm.cs

示例3: GetFacets

 public override IEnumerable<SEOAnalysisFacet> GetFacets(Webpage webpage, HtmlNode document, string analysisTerm)
 {
     string titleText = document.GetElementText("title");
     if (titleText != null && titleText.Contains(analysisTerm, StringComparison.OrdinalIgnoreCase))
     {
         if (titleText.StartsWith(analysisTerm))
             yield return
                 GetFacet("Title contains term", SEOAnalysisStatus.Success,
                     string.Format("The title starts with the term '{0}', which is considered to improve rankings", analysisTerm));
         else
         {
             yield return
                 GetFacet("Title contains term", SEOAnalysisStatus.CanBeImproved,
                     string.Format(
                         "The title contains the term '{0}'. To improve this, consider moving it to the start of the title, as this is considered to improve rankings",
                         analysisTerm));
         }
     }
     else
         yield return
             GetFacet("Title contains term", SEOAnalysisStatus.Error,
                 string.Format("The title does not contain '{0}'", analysisTerm));
 }
开发者ID:neozhu,项目名称:MrCMS,代码行数:23,代码来源:TitleContainsTerm.cs


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