本文整理汇总了C#中csExWB.GetElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# csExWB.GetElementsByTagName方法的具体用法?C# csExWB.GetElementsByTagName怎么用?C# csExWB.GetElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类csExWB
的用法示例。
在下文中一共展示了csExWB.GetElementsByTagName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadDocumentInfo
/// <summary>
/// Loads document information into the Tree
/// Uses each node.Tag to store information
/// </summary>
/// <param name="pWB">An instance of csExWB.cEXWB</param>
public void LoadDocumentInfo(csExWB.cEXWB pWB)
{
treeDocInfo.Nodes.Clear();
txtDocInfo.Clear();
IHTMLDocument2 doc2 = null;
//First fill in the main document information
TreeNode root = treeDocInfo.Nodes.Add("Main Document");
TreeNode node = root.Nodes.Add("HTML");
TreeNode subnode = node.Nodes.Add("Title");
subnode.Tag = pWB.GetTitle(true);
doc2 = (IHTMLDocument2)pWB.WebbrowserObject.Document;
subnode = node.Nodes.Add("URL");
subnode.Tag = doc2.url;
subnode = node.Nodes.Add("Domain");
subnode.Tag = doc2.domain;
subnode = node.Nodes.Add("Protocol");
subnode.Tag = doc2.protocol;
subnode = node.Nodes.Add("Cookie");
subnode.Tag = doc2.cookie;
subnode = node.Nodes.Add("Referrer");
subnode.Tag = doc2.referrer;
subnode = node.Nodes.Add("Last Modified");
subnode.Tag = doc2.lastModified;
subnode = node.Nodes.Add("Source");
subnode.Tag = pWB.GetSource(pWB.WebbrowserObject); //pWB.GetSource(true);
subnode = node.Nodes.Add("Text");
subnode.Tag = pWB.GetText(true);
//or pWB.GetImages(true);
IHTMLElementCollection elems = (IHTMLElementCollection)doc2.images;
subnode = node.Nodes.Add("Images");
IHTMLImgElement img = null;
string str = string.Empty;
foreach (IHTMLElement elem in elems)
{
if (elem != null)
{
img = (IHTMLImgElement)elem;
str += Environment.NewLine + img.src;
}
}
subnode.Tag = str;
//
//Other collections
//
//elems = (IHTMLElementCollection)doc2.anchors;
//subnode = node.Nodes.Add("Links");
//elems = (IHTMLElementCollection)doc2.scripts;
//subnode = node.Nodes.Add("Java Scripts");
//IHTMLMetaElement meta = null;
//IHTMLElementCollection col = (IHTMLElementCollection)pWB.GetElementsByTagName(true, "meta");
//foreach (IHTMLElement elem in col)
//{
// meta = (IHTMLMetaElement)elem;
// if (meta != null)
// {
// AllForms.m_frmLog.AppendToLog("\r\nhttpEquiv=" + meta.httpEquiv + "\r\nname=" + meta.name +
// "\r\nurl=" + meta.url + "\r\ncharset=" + meta.charset + "\r\ncontent=" + meta.content);
// }
// meta = null;
//}
//IFRAME
//elem.getAttribute("src", 0) + "\r\n" +
IHTMLElementCollection col = pWB.GetElementsByTagName(true, "IFRAME") as IHTMLElementCollection;
if (col != null)
{
foreach (IHTMLElement elem in col)
{
if (elem != null)
{
subnode = root.Nodes.Add("IFrame");
subnode.Tag = elem.outerHTML;
}
}
}
//If frameset, we add the frames
if (pWB.IsFrameset())
{
TreeNode framenode = root.Nodes.Add("FRAMES");
List<IWebBrowser2> frames = pWB.GetFrames();
foreach (IWebBrowser2 wb in frames)
{
node = framenode.Nodes.Add("HTML");
subnode = node.Nodes.Add("Title");
subnode.Tag = pWB.GetTitle(wb);
doc2 = (IHTMLDocument2)wb.Document;
subnode = node.Nodes.Add("URL");
//.........这里部分代码省略.........