Jump to content
Windows Dragon

IHTMLElement problemas com o innerHTML

Recommended Posts

Windows Dragon

Boas pessoal, eu tenho o seguinte código

Imports System.Net
Imports System.Text.RegularExpressions
Imports System.IO
Imports System.Threading
Imports mshtml
Public Class MainFRM
Dim myPageSource As String
Dim tables As String()
Dim wb As WebBrowser
Private Sub MainFRM_Load(sender As Object, e As EventArgs) Handles MyBase.Load
	wb = New WebBrowser
	wb.ScriptErrorsSuppressed = True
	Dim th As New Thread(AddressOf LoadData)
	th.Start()
End Sub
Private Sub LoadData()
	Dim url As String = http://www.website.com
	Dim myWebRequest As HttpWebRequest = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)
	myWebRequest.Method = "GET"
	Dim myWebResponse As HttpWebResponse = DirectCast(myWebRequest.GetResponse(), HttpWebResponse)
	Dim myWebSource As New StreamReader(myWebResponse.GetResponseStream())
	myPageSource = myWebSource.ReadToEnd()
	myWebResponse.Close()
	tables = Regex.Split(myPageSource, "table")		
	Dim htmlDoc As IHTMLDocument2 = New HTMLDocumentClass()
	htmlDoc.write(tables(5))
	Dim allElements As IHTMLElementCollection = htmlDoc.all
	Dim values As IHTMLElementCollection = allElements.tags("TD")
	For Each row As IHTMLElement In values
		If row.getAttribute("classname") = "ewTableRow" Then
			MsgBox(row.innerHTML)
		End If
	Next
End Sub
End Class

e o tables(5) contem o seguinte conteúdo

class="ewTable" style="text-align: center; vertical-align: top; margin-top: 10px;">
					<tr bgcolor="#eff4f4">
						<td colspan="3" style="border-right: solid 1px #000; border-left: solid 1px #000;
							border-top: solid 1px #000; border-bottom: solid 1px #000; text-align: center">
							<span><strong style="width: 100%;">ONTEM</strong></span>
						</td>
					</tr>
					<tr bgcolor="#eff4f4">
						<td style="border-right: solid 1px #000; border-left: solid 1px #000; border-top: solid 1px #000;
							width: 70px;">
							<span><strong>Values1</strong></span>
						</td>
						<td style="border-right: solid 1px #000; border-left: solid 1px #000; border-top: solid 1px #000;
							width: 70px;">
							<span><strong>values2</strong></span>
						</td>
						<td style="border-right: solid 1px #000; border-left: solid 1px #000; border-top: solid 1px #000;
							width: 70px;">
							<span><strong>values3</strong></span>
						</td>
					</tr>
					<tr>
						<td class="ewTableRow" style="border-right: solid 1px #000; border-left: solid 1px #000;
							border-bottom: solid 1px #000;">
							<strong>
								389
							</strong>
						</td>
						<td class="ewTableRow" style="border-right: solid 1px #000; border-left: solid 1px #000;
							border-bottom: solid 1px #000;">
							<strong>
								7.228
							</strong>
						</td>
						<td class="ewTableRow" style="border-right: solid 1px #000; border-left: solid 1px #000;
							border-bottom: solid 1px #000;">
							<strong>
								1.975
							</strong>
						</td>
					</tr>
				</

mas aqui MsgBox(row.innerHTML) não me dá output de nada msm que mude para innerText.

Mas o outterHTML funciona

Como é que eu consigo obter o que está dentro desse elemento?

Edited by Windows Dragon

Share this post


Link to post
Share on other sites
Windows Dragon

post no thread errado desculpem

Edited by Windows Dragon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.