我的应用程序应该解析html并将内容加载到列表框中。我可以通过webclient获取html,但在解析时卡住了。
我听说过Htmlagilitypack和Fizzler,但找不到任何关于它们用法的教程或示例。
我需要一些帮助,从下面显示的html文档中抓取"first_content“和"second_content”到列表框中。
<html>
<body>
<div>
<section>
<article>
<header>
<hgroup>
<h1>
first_content
</h1>
</hgroup>
</header>
<ul>
<li>
second_content
</li>
</ul>
</article>
</section>
</div>
</body>
</html>发布于 2013-02-08 06:17:27
HtmlAgilityPack是必由之路,我已经在WCF,Windows Phone和现在的WinRt中使用过它,完全成功了,有关教程,请查看this blog post
发布于 2013-02-12 04:11:57
您可以使用XPath。例如..。
var html = "<html><body><div><section><article><header><hgroup><h1>first_content</h1></hgroup></header><ul><li>second_content</li></ul></article> </section></div></body></html>";
var doc = new XmlDocument();
doc.LoadXml(html);
var txt1 = doc.SelectSingleNode("/html/body/div/section/article/header/hgroup/h1").InnerText;
var txt2 = doc.SelectSingleNode("/html/body/div/section/article/ul/li").InnerText;https://stackoverflow.com/questions/14756076
复制相似问题