将HtmlAgilityPack.HtmlNode转换为字符串

c# html html-agility-pack string

private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("In devolopment","Error", MessageBoxButtons.OK);
            HtmlAgilityPack.HtmlWeb hw = new HtmlAgilityPack.HtmlWeb();
            HtmlAgilityPack.HtmlDocument doc = hw.Load("https://www.stackoverflow.com");
            foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
            {
                usercon(link);
            }

        }

public void usercon(string toprint)
        {
            richTextBox1.Text += "\r\n";
            richTextBox1.Text += toprint;
            //richTextBox1.
        }

我需要能够将link转换为字符串,以便可以在函数usercon

这是我第一次使用HtmlAgilityPack

一般承认的答案

根据此处找到的源代码: https//htmlagilitypack.codeplex.com/SourceControl/latest#Release/1_4_0/HtmlAgilityPack/HtmlNode.cs
另请参阅(新)文档: http ://html-agility-pack.net/outer-html HtmlNode在GitHub上有一个OuterHtml属性及其源代码。

private void button2_Click(object sender, EventArgs e)
{
    MessageBox.Show("In devolopment","Error", MessageBoxButtons.OK);
    HtmlAgilityPack.HtmlWeb hw = new HtmlAgilityPack.HtmlWeb();
    HtmlAgilityPack.HtmlDocument doc = hw.Load("https://www.stackoverflow.com");
    foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
    {
        usercon(link.OuterHtml);
    }
}



许可下: CC-BY-SA with attribution
不隶属于 Stack Overflow
这个KB合法吗? 是的,了解原因
许可下: CC-BY-SA with attribution
不隶属于 Stack Overflow
这个KB合法吗? 是的,了解原因