如何使用C#在html源代码中查找特定的div标签 [英] how to find specific div tag in html source using C#

查看:611
本文介绍了如何使用C#在html源代码中查找特定的div标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找出html源码的ttwo div标签之间的数据如何实现这一点..





我想从总html源代码中获取以下部分。



i want to find out the data between the ttwo div tags of html source how van i acheive this..


I want the following part from the total html source.

<div class="important-dates domain-data">
<header>
<!-- span title="We are still waiting for this data to be fetched." rel="tooltip" class="fetch-waiting"></span -->
<span title="This data has been fetched." rel="tooltip" class="fetch-success" style="display:block"></span>
<!-- span title="We were unable to fetch this data." rel="tooltip" class="fetch-fail"></span -->
<h5>Important Dates
<a class="btn tiny pjax-btn" href="/domain-history/sunlightit.com">More Info</a></h5>
</header>

<table>
<tbody>
    <tr>
<th>Expires On</th>
<td><span data-bind-domain="expiration_date" style="visibility: visible;">September 20, 2013</span></td>
</tr>
        <tr>
<th>Registered On</th>
<td><span data-bind-domain="expiration_date" style="visibility: visible;">September 20, 2006</span></td>
</tr>
        <tr>
<th>Updated On</th>
<td><span data-bind-domain="expiration_date" style="visibility: visible;">November 03, 2012</span></td>
</tr>
    </tbody></table>
</div>







我怎么能实现这个。



请帮助我.......

提前感谢.....




how can i acheive this.

pls help me .......
thanks in advance.....

推荐答案

声明 id div 的code>然后设置 div的 runat 属性server如下所示。

Declare id of your div and then set runat property of your div to "server" as below.
<div id="myDiv" class="important-dates domain-data" runat="server"></div>



然后访问 div 如下所示。


Then access inner HTML of your div as below.

string sHTML= myDiv.InnerHtml;


如果我做对了,你从某个地方获取html代码 - 而不是你的代码正在发出它。而你想从中提取一部分。比试用 HTML Agility Pack库 [ ^ ]
If I got it right, you fetch the html code from somewhere - not your code is emitting it. And you want to extract a portion from it. Than try HTML Agility Pack library[^]


asign runate =server和id =name
asign runate="server" and id="name"


这篇关于如何使用C#在html源代码中查找特定的div标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆