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