/// <summary> /// Transform link tags to HtmlAnchorTag. /// </summary> /// <param name="htmlDoc"> The HTML DOM Document to process.</param> /// <returns> A HtmlTagBaseList.</returns> public static HtmlTagBaseList TransformLinksElements(IHTMLDocument2 htmlDoc) { HtmlTagBaseList list = new HtmlTagBaseList(); IHTMLElementCollection coll = (IHTMLElementCollection)htmlDoc.all.tags("link"); foreach ( object obj in coll ) { if ( obj is IHTMLLinkElement ) { IHTMLLinkElement link = (IHTMLLinkElement)obj; HtmlLinkTag linkTag = new HtmlLinkTag(); linkTag.HRef = link.href; linkTag.MimeType = link.type; list.Add(linkTag); } // else // { // System.Windows.Forms.MessageBox.Show(((mshtml.IHTMLElement)obj).outerHTML); // } } return list; }
/// <summary> /// Transform frame elements to HtmlLinkTag array. /// </summary> /// <param name="htmlDoc"> The HTML DOM Document to process.</param> /// <returns> A HtmlTagBaseList.</returns> public static HtmlTagBaseList TransformFrameElements(IHTMLDocument2 htmlDoc) { HtmlTagBaseList list = new HtmlTagBaseList(); IHTMLElementCollection coll = (IHTMLElementCollection)htmlDoc.all.tags("frame"); foreach ( object obj in coll ) { if ( obj is IHTMLFrameBase ) { IHTMLFrameBase a = (IHTMLFrameBase)obj; HtmlLinkTag frame = new HtmlLinkTag(); frame.HRef = a.src; list.Add(frame); } } return list; }