HtmlElementCollection urltemp = web.Document.GetElementsByTagName("ul").GetElementsByName("a");
我这样写没有报错,但获取不到东西,ul里面是<LI><A href="http://xxxxxx>中文</A></LI>
请大侠指教
7 个解决方案
#1
HtmlElementCollection urltemp = web.Document.GetElementsByTagName("ul").firtChild
#2
HtmlElementCollection urltemp = web.Document.GetElementsByTagName("ul");
foreach(HtmlElement element){
HtmlElementCollection temp = element.GetElementsByTagName("a");
}
foreach(HtmlElement element){
HtmlElementCollection temp = element.GetElementsByTagName("a");
}
#3
ul 下面还有li的,a 是在li里面的
#4
jquery
$("ul a")
$("ul a")
#5
这是C#不是JS
#6
System.Windows.Forms.HtmlElementCollection listhtml = this.webBrowser1.Document.GetElementsByTagName("ul");
foreach (System.Windows.Forms.HtmlElement ul in listhtml)
{
HtmlElementCollection lista = ul.GetElementsByTagName("a");
}
}
foreach (System.Windows.Forms.HtmlElement ul in listhtml)
{
HtmlElementCollection lista = ul.GetElementsByTagName("a");
}
}
#7
问题解决,但1楼的不行,
#1
HtmlElementCollection urltemp = web.Document.GetElementsByTagName("ul").firtChild
#2
HtmlElementCollection urltemp = web.Document.GetElementsByTagName("ul");
foreach(HtmlElement element){
HtmlElementCollection temp = element.GetElementsByTagName("a");
}
foreach(HtmlElement element){
HtmlElementCollection temp = element.GetElementsByTagName("a");
}
#3
ul 下面还有li的,a 是在li里面的
#4
jquery
$("ul a")
$("ul a")
#5
这是C#不是JS
#6
System.Windows.Forms.HtmlElementCollection listhtml = this.webBrowser1.Document.GetElementsByTagName("ul");
foreach (System.Windows.Forms.HtmlElement ul in listhtml)
{
HtmlElementCollection lista = ul.GetElementsByTagName("a");
}
}
foreach (System.Windows.Forms.HtmlElement ul in listhtml)
{
HtmlElementCollection lista = ul.GetElementsByTagName("a");
}
}
#7
问题解决,但1楼的不行,