在文本框中显示HTML的特定部分

时间:2014-02-21 19:21:00

标签: c# html windows-phone-7 hyperlink html-agility-pack

我想在html-page的文本框中显示WP7-app (C#)的特定部分。经过一段网上搜索,我发现了这个:

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml("http://www.positief-project.be/?p=532");
string links = doc.DocumentNode
    .Descendants("section")
    .Where(section => section.Attributes["class"] != null && 
     section.Attributes["class"].Value == "article-content").ToString();
txbContent.Text = links;

这不会出错,但也不起作用。如何在文本框中显示它?

1 个答案:

答案 0 :(得分:0)

jQuery是一个选项吗?

HTML

<div class="section">
    <div class="article-content">some foo 1</div>
    <div class="article-content">some foo 2</div>
    <div class="article-content">some foo 3</div>
<div class="article-content">some foo 4</div>
</div>
<br>
<input type="text" id="tbContent" />

的jQuery

$(document).ready(function () {
    var content;
    $('.article-content').each(function(i, obj){
        content += obj.innerHTML;
    });
    $('#tbContent').val(content);
});

请参阅此小提琴http://jsfiddle.net/rodhartzell/Fk2xM/