解决方案 »
- 动态创建ToolBar的问题
- 急问!!WinForm窗体中使用了TopMost,让窗体在最前面表示后带来的问题。请帮帮忙!!
- c#引用类型对象的删除问题
- winform中如何读取txt文件并显示
- ?怎样将DataGridview中的不符合规则的某一行变换颜色,怎样将水晶报表与DataGridview中的信息联系起来?
- 如何移动Label控件(加分100)在线等,紧急!!!
- JS 获取 asp.net的返回值
- webBrowser获取第一加载有数据的时间。
- 可否手动增加控件?可能表述的不太正确,请看内容!!!
- 我想在合适位置比如一个单元格里 写Response的信息怎么写?
- 大文本的读取
- 高手进来看看 日期格式问题
for (int i = 0; i < he.All.Count; i++)
{
if (he.All[i].GetAttribute("属性").IndexOf("值") >= 0)
{
}
}
HtmlElementCollection hc = this.webBrow.Document.Links;
foreach (HtmlElement he in hc)
{
if (he.GetAttribute("href").Contains("OfficeDocBrower.aspx"))
{
//he.SetAttribute("target", "");
//he.OuterHtml.Replace("target=_blank", "");
}
}
不要针对这段HTML,谁知道别的表单name属性是什么?我要能“遍历表单元素”的程序!
那就webClient GET HTML下来,检索<form></form>的位置
HtmlDocument htm = this.webBrowser1.Document;
HtmlElementCollection all = htm.All;
for (int i = 0; i < all.Count; i++)
{
HtmlElement elem = all[i];
if (elem.TagName.ToLower() == type)
{
s=elem.GetAttribute("name").ToString();
}
}
HtmlElementCollection htmlTabs = webBrowser1.Document.GetElementsByTagName("table");
if(htmlTabs!=null&&htmlTabs.length>0)
{
HtmlElement htmlTable = htmlElements[0];
HtmlElementCollection htmlRows = htmlElement.GetElementsByTagName("tr");
HtmlElementCollection htmlCells = null;
foreach (HtmlElement htmlRow in htmlRows)
{
htmlCells = htmlRow.GetElementsByTagName("td");
foreach (HtmlElement htmlCell in htmlCells)
{
if (htmlCell.InnerText!=null)
{
strValue = htmlCell.InnerText.Trim();
}
}
}
}
递归遍历
HtmlElementCollection forms= doc.Forms;
foreach (HtmlElement form in forms)
{
foreach (HtmlElement element in form.All)
{
if (element.GetAttribute("type") == "hidden")
{
Console.WriteLine(element.GetAttribute("name"));
Console.WriteLine(element.GetAttribute("value"));
}
}
}
HtmlElementCollection elements = myWebBrowser.Document.All;
foreach (HtmlElement element in elements)
{
if ("hidden" == element.GetAttribute("type"))
{
string str = "name=" + element.GetAttribute("name")
+ " value=" + element.GetAttribute("value"); listBox1.Items.Add(str);
}
}
这段代码有什么问题?
{
}