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


C# IHtmlElement.InnerHtml方法代码示例

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


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

示例1: BindElement

    private void BindElement( IHtmlElement element, Dictionary<string, string> dictionary )
    {
      var text = element.InnerHtml();

      foreach ( var pair in dictionary )
        text = text.Replace( string.Format( "#{0}#", pair.Key ), pair.Value );


      element.InnerHtml( text );
    }
开发者ID:ajayumi,项目名称:Jumony,代码行数:10,代码来源:LiteralBinder.cs

示例2: BindSimpleData

        private void BindSimpleData( IHtmlElement element, object data )
        {
            var htmlContent = data as IHtmlContent;

              if ( htmlContent != null )
            element.InnerHtml( htmlContent.ToHtmlString() );
              else
            element.InnerText( data.ToString() );
        }
开发者ID:neo2018,项目名称:Jumony,代码行数:9,代码来源:HtmlBinder.cs

示例3: BindElement

    /// <summary>
    /// 对 HTML 中的 script 元素进行绑定
    /// </summary>
    /// <param name="context">当前绑定上下文</param>
    /// <param name="element">当前绑定的元素(仅会对 script 元素起作用)</param>
    /// <returns>永远返回 false,表示其他绑定器可以继续执行</returns>
    public void BindElement( HtmlBindingContext context, IHtmlElement element )
    {
      if ( !element.Name.EqualsIgnoreCase( "script" ) )
        return;


      var script = element.InnerHtml();

      script = scriptBindingExpression.Replace( script, match =>
        {
          var expression = BindingExpression.ParseExpression( match.Groups["expression"].Value );
          if ( expression == null )
            return match.Value;

          object dataObject = context.GetValue( expression );
          var valueExpression = serializer.Serialize( dataObject );

          return match.Groups["declare"].Value + valueExpression + ";";
        } );


      element.InnerHtml( script );
    }
开发者ID:ajayumi,项目名称:Jumony,代码行数:29,代码来源:ScriptBinder.cs

示例4: BuildEntity

        private ExamItem BuildEntity(int moduleId, IHtmlElement item)
        {
            try
            {
                var id_element = item.FindFirst(@"tr[valign]>td");

                var match = Regex.Match(id_element.InnerText(), @"\d+");

                int id = Convert.ToInt32(match.Value.Trim());
                string title = id_element.NextElement().InnerText().Trim().RemoveHtml().RemoveHtmlEncode();
                string answer = item.FindFirst("div[id]").InnerText().Trim().RemoveHtmlEncode();
                string examType = item.PreviousElement().Descendants("td")
                                                        .ElementAt(1)
                                                        .InnerText().Trim().RemoveHtml().RemoveHtmlEncode();

                if (answer.StartsWith("答案:"))
                {
                    answer = answer.Substring(3).Trim();
                }

                var itemType = ItemTypeService.GetByText(examType);
                if (itemType == null)
                {
                    logger.Info(string.Format("未匹配的题目类别[{0}],ExamId=[{1}]", examType, id));
                }

                var model = new ExamItem()
                {
                    Id = id,
                    Title = title,
                    Answer = answer,
                    OriginalHtml = item.InnerHtml(),
                    Module_Id = moduleId,
                    ItemType = itemType != null ? itemType.Id : 0,
                    CreateTime = DateTime.Now,
                    DelFlag = false
                };
                return model;
            }
            catch (Exception ex)
            {
                WriteLog(item.ToString(), ex.Message);
                throw;
            }
        }
开发者ID:john123951,项目名称:sweetfly.net,代码行数:45,代码来源:OldHandler.cs

示例5: BuildEntity

        private ExamItem BuildEntity(int moduleId, IHtmlElement item)
        {
            string selector = @"td[width]";
            if (false == item.Exists(selector)) { return null; }

            var id_element = item.FindFirst(selector);
            if (id_element == null) { return null; }
            try
            {

                var match = Regex.Match(id_element.InnerText(), @"\d+");

                int id = Convert.ToInt32(match.Value.ToString().Trim());
                string title = id_element.Parent().FindFirst(@".MsoNormal>span").InnerText().Trim().RemoveHtml().RemoveHtmlEncode();
                string answer = item.FindFirst("#answer").InnerText().Trim();
                string strExamType = item.FindFirst(".st_title").InnerText();
                string examType = Regex.Match(strExamType, @"(?<=、).*").Value.Trim();

                if (answer.StartsWith("答案:"))
                {
                    answer = answer.Substring(3).Trim();
                }

                var itemType = ItemTypeService.GetByText(examType);
                if (itemType == null)
                {
                    logger.Info(string.Format("未匹配的题目类别[{0}],ExamId=[{1}]", examType, id));
                }

                var model = new ExamItem()
                {
                    Id = id,
                    Title = title,
                    Answer = answer,
                    OriginalHtml = item.InnerHtml(),
                    Module_Id = moduleId,
                    ItemType = itemType != null ? itemType.Id : 0,
                    CreateTime = DateTime.Now,
                    DelFlag = false
                };
                return model;
            }
            catch (Exception ex)
            {
                WriteLog(item.ToString(), ex.Message);
                throw;
            }

        }
开发者ID:john123951,项目名称:sweetfly.net,代码行数:49,代码来源:NormalHandler.cs


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