Vb.Net WinForms アプリケーションで SHDocVw.InternetExplorer API を使用して、Internet Explorer から要素を取得しています。親ドキュメントとフレーム要素内の要素には簡単にアクセスできますが、「埋め込み」コンテナ内の要素にはアクセスできません。サンプルコードは次のとおりです。
Dim ie As SHDocVw.InternetExplorer
ie.Navigate("Some URL")
ie.Visible = True
Dim ieDoc As mshtml.IHTMLDocument2 = ie.Document
'All Elements
Dim allElements = ieDoc.all
'Frames
Dim allFrames = ieDoc.frames
'Fetch each frame and use its document to get all elements
Dim allEmbed = ieDoc.embeds
'How to fetch document inside embed to access its elements?
サンプルの html は次のとおりです。
サンプル.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
</head>
<body>
<embed src="test.html" name="test1"/>
</body>
</html>
Test.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample</title>
</head>
<body bgcolor="#FFFFFF">
<button>Button1</button>
<label>Test 1</label>
</body>
</html>
「embed」タグを使用して、Sample.html にロードされた Test.html 内のボタンとラベルにアクセスするにはどうすればよいですか?
編集1:
私の調査によると、「オブジェクト」要素の .contentDocument プロパティを使用して「オブジェクト」コンテナ内のドキュメントにアクセスできますが、「埋め込み」コンテナでは同じことが機能しません。
「埋め込み」コンテナの getSVGDocument() プロパティを使用して comObject を取得できますが、それを mshtml.IHTMLDocument2 にキャストすることはできません