解析HTML表在C# [英] Parsing HTML Table in C#
本文介绍了解析HTML表在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含表的HTML页面,我想分析该表在C#Windows窗体
I have an html page which contains a table and i want to parse that table in C# windows form
的 http://www.mufap.com.pk/payout-report.php?tab=01
这是我想分析我曾尝试
> Foreach(Htmlnode a in document.getelementbyname("tr"))
{
richtextbox1.text=a.innertext;
}
我已经尝试了一些这样的事,但它不会给我以表格形式我只是打印所有TRS所以请帮助我对此感谢名单
对不起我的英语水平。
i have tried some thing like this but it wont give me in tabular form as i am simply printing all trs so please help me regarding this thanx sorry for my english.
推荐答案
使用<一个HREF =http://htmlagilitypack.codeplex.com/> HTML敏捷性包
WebClient webClient = new WebClient();
string page = webClient.DownloadString("http://www.mufap.com.pk/payout-report.php?tab=01");
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
List<List<string>> table = doc.DocumentNode.SelectSingleNode("//table[@class='mydata']")
.Descendants("tr")
.Skip(1)
.Where(tr=>tr.Elements("td").Count()>1)
.Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
.ToList();
这篇关于解析HTML表在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文