本文整理汇总了C#中mshtml.getElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# mshtml.getElementsByTagName方法的具体用法?C# mshtml.getElementsByTagName怎么用?C# mshtml.getElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mshtml
的用法示例。
在下文中一共展示了mshtml.getElementsByTagName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getHtmlForms
public void getHtmlForms(mshtml.HTMLDocument doc)
{
mshtml.IHTMLElementCollection all;
mshtml.IHTMLElementCollection chi;
bool cont;
int count, n;
string basePath;
refreshFormData();
// TODO: Frames
// Define base path
basePath = doc.url;
cont = true;
count = 0;
while (cont == true)
{
count++;
if (basePath.Substring(basePath.Length - 1, 1) == "/" && count > 1)
{
cont = false;
}
else
{
basePath = basePath.Substring(0, basePath.Length - 1);
}
}
// Read forms
all = doc.getElementsByTagName("form");
foreach(mshtml.IHTMLFormElement elm in all)
{
DataRow dr = dtForm.NewRow();
dr["form"] = elm.name;
dr["action"] = getAction(elm.action, basePath);
dr["method"] = elm.method;
dtForm.Rows.Add(dr);
}
// TODO: radiobutton, checkbox
// Read input fields
all = doc.getElementsByTagName("input");
foreach(mshtml.IHTMLInputElement elm in all)
{
DataRow dr = dtFormItem.NewRow();
dr["form"] = elm.form.name;
dr["formaction"]= getAction(elm.form.action, basePath);
dr["name"] = elm.name;
dr["type"] = elm.type;
dr["value"] = elm.value;
if (dr["name"].ToString().Trim().Length > 0)
{
dtFormItem.Rows.Add(dr);
}
}
// Read text areas
all = doc.getElementsByTagName("textarea");
foreach(mshtml.IHTMLTextAreaElement elm in all)
{
DataRow dr = dtFormItem.NewRow();
dr["form"] = elm.form.name;
dr["formaction"]= getAction(elm.form.action, basePath);
dr["name"] = elm.name;
dr["type"] = elm.type;
dr["value"] = elm.value;
if (dr["name"].ToString().Trim().Length > 0)
{
dtFormItem.Rows.Add(dr);
}
}
// Read select elements
all = doc.getElementsByTagName("select");
foreach(mshtml.IHTMLSelectElement elm in all)
{
DataRow dr = dtFormItem.NewRow();
dr["form"] = elm.form.name;
dr["formaction"]= getAction(elm.form.action, basePath);
dr["name"] = elm.name;
dr["type"] = elm.type;
dr["value"] = elm.value;
if (dr["name"].ToString().Trim().Length > 0)
{
dtFormItem.Rows.Add(dr);
}
}
// Read radio buttons
all = doc.getElementsByTagName("radio");
foreach(mshtml.IHTMLOptionButtonElement elm in all)
{
bool bAdded = false;
// Be sure that you didnt add it before
foreach(DataRow dr in dtFormItem.Rows)
{
//.........这里部分代码省略.........