简体   繁体   中英

Show specific section of HTML in textbox

I want to show a specific section of a html-page in a textbox in a WP7-app (C#) . After a bit of searching online I found this:

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;

This doesn't give an error, but doesn't work either. How can I make it show in the text box?

Is jQuery an option?

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);
});

See this fiddle http://jsfiddle.net/rodhartzell/Fk2xM/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM