2013-10-21 99 views
0
string entry = Titleentry.Text; 

HtmlElementCollection theElementCollection; 
HtmlDocument filters = webBrowser1.Document; 

theElementCollection = webBrowser1.Document.GetElementsByTagName("input"); 

foreach (HtmlElement curElement in theElementCollection) 
{ 
    if ((curElement.GetAttribute("id").ToString() == "searchTitle")) 
    { 
     curElement.SetAttribute("value", entry); 
    } 
} 

filters.GetElementById("filterSortBy").GetAttribute("option").Select("price_low_high"); 

theElementCollection = webBrowser1.Document.GetElementsByTagName("button"); 

foreach (HtmlElement curElement in theElementCollection) 
{ 
    if (curElement.GetAttribute("id").Equals("searchSubmit")) 
    { 
     curElement.InvokeMember("click"); 
    } 
} 

標記的語句給我下面的消息:使用GetElementsById搜索網站

錯誤1類型參數的方法「System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable ,System.Func)'不能從使用情況中推斷出來。嘗試明確指定類型參數。

什麼,我試圖做的是從網站獲得的ID元素,因爲如果我嘗試按標記名稱的元素它是選擇不正確的元素

我嘗試使用HTML的集合,但它說不能隱式轉換成html元素到html集合

+0

任何人都在意幫助我嗎? –

回答

0

首先,Select需要一個Func<TSource, TResult>,不只是一個字符串說你想要什麼。其次,你爲什麼試圖首先使用SelectGetAttribute返回屬性值的字符串。只需聲明一個字符串來捕獲值。

string option = filters.GetElementById("filterSortBy").GetAttribute("option"); 
+0

我正在使用選擇,因爲它的選項列表,因爲即時通訊非常新手在C#我是這是常識,因爲它的選擇。使用後,如何選擇價格從低到高的期權價值? –