简体   繁体   English

在C#中使用XPath提取div内容

[英]Extract div content with XPath in C#

I am doing a web scrape and getting back the html. 我正在网上抓取并找回HTML。 I want to get all the div content from the html with XPath. 我想使用XPath从html获取所有div内容。 Here is a snippet of the html: 这是html的代码段:

<TD style="background-color:Gainsboro;" class="a83c"><DIV style="word-
wrap:break-word;" class="a83">17173,1</DIV></TD>
<TD style="background-color:Gainsboro;" class="a87c"><DIV style="word-
wrap:break-word;" class="a87">14865,0</DIV></TD>

So from this example i would want to extract: 17173,1 and 14865,0 所以我想从这个例子中提取:17173,1和14865,0

Please could someone tell me how I would do this using XPath, or if it is easier using Regex? 请有人告诉我如何使用XPath进行此操作,或者是否可以使用Regex轻松进行操作?

Thanks. 谢谢。

您应该尝试HTML Agility Pack及其xpath支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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