0
HTML的幫助事業部之間的字符串是:掌握類名
<div class="topheader-left common-txt" style="color: #ffffff;vertical-align:top;padding-top:3px">
Sunday, April 28, 2013 | 08:07:07 PM
</div>
我需要的時間是8點07分07秒,我將轉換爲時間價值。 我正在使用此代碼獲取Div區域的字符串。獲取子串。爲什麼這不起作用?
HtmlElementCollection theElementCollection = default(HtmlElementCollection);
theElementCollection = webBrowser1.Document.GetElementsByTagName("div");
foreach (HtmlElement curElement in theElementCollection)
{
if (curElement.GetAttribute("class").ToString() == "topheader-left common-txt")
{
MessageBox.Show(curElement.GetAttribute("InnerText"));
}
}
我期望這個使用目的內置HTML解析器如[HTML敏捷性包(http://htmlagilitypack.codeplex.com/)(的XPath),或要容易得多[CsQuery ](https://github.com/jamietre/CsQuery)(jQuery選擇器語法) – Oded 2013-04-28 16:27:34
已配置HTML Agility Pack。現在代碼是什麼? – Braheen 2013-04-28 16:38:57