Geckofx元素

时间:2014-03-17 23:28:26

标签: c# geckofx

所以我有一个表格,其中有一些td和一个来自.net IE的webbrowser我可以从elTB元素中获取元素

            HtmlElementCollection elTB = wb1.Document.GetElementsByTagName("TABLE");
            HtmlElementCollection elc = elTB[2].GetElementsByTagName("TD");

但是,如果我尝试使用geckofx,它总能给我错误,任何人都可以帮忙吗? (我是geckofx和c#的新手)

            GeckoElementCollection tables = wb1.Document.GetElementsByTagName("TABLE");
            GeckoElementCollection TD = tables[2].GetElementsByTagName("A");

3 个答案:

答案 0 :(得分:0)

这有效:

      Gecko.Collections.IDomHtmlCollection<GeckoElement> foo = item.GetElementsByTagName("table");
      GeckoHtmlElement bar = foo[0] as GeckoHtmlElement;
      GeckoElementCollection TD = bar.GetElementsByTagName("a");

大多数时候我都想知道计算机是半智能的,还是仅仅是我。

答案 1 :(得分:0)

坦克的答案我已经找到了解决方案:P但是它和你的一样

            GeckoElement elDIVa = wb1.Document.GetElementById("element id");
            Gecko.Collections.IDomHtmlCollection<GeckoElement> elA = elDIVa.GetElementsByTagName("A");
            foreach (GeckoElement el in elA)
            { etc etc }

答案 2 :(得分:0)

您的问题来自大写,IE使用大写的HTML标记,GeckoFX使用小写,所以您应该将其更改为:

var tables = wb1.Document.GetElementsByTagName("table");
var TD = tables[2].GetElementsByTagName("a");

我相信它会奏效。