Hi,
I need to Read a HTML File and retrieve Tag value and attribute value.
In HTMLDocument there is no LOAD function to load a html file,but there are methods like getElementByTagName.
How to load a html file in htmldocument class?
Printable View
Hi,
I need to Read a HTML File and retrieve Tag value and attribute value.
In HTMLDocument there is no LOAD function to load a html file,but there are methods like getElementByTagName.
How to load a html file in htmldocument class?
try this?
vb Code:
mc_OutputWebBrowser.Document.Body.InnerHtml = "<b>This is a test</b>"
Kris
whats that "mc_OutputWebBrowser"? its an object of webbrowser control or something else.
i tried like this but am getting "Object reference ..." exception.vb Code:
Dim WebOC As New WebBrowser WebOC.Document.Body.InnerHtml = "<b>This is a test</b>"
If you want to parse html file, I would suggest two methods.
1.Parse the HTML file using regular expressions
2. Load the HTML in a webbrowser and use the document.getelementbyid method
3. Or try this parser. (not I have never tried)
"2. Load the HTML in a webbrowser and use the document.getelementbyid method"
How to load the HTML File in webrowser?
i don't need a control in forms.. i just want to get the values inside tags.
Hope this helps
Code:Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim browser As New WebBrowser
AddHandler browser.DocumentCompleted, AddressOf browser_LoadCompleted
browser.Visible = False
'Add the Html
browser.DocumentText = "<html><body>Please enter your name:<br/>" & _
"<input type='text' name='userName' id='userName' value='testUsername'/><br/>" & _
"<a href='http://www.microsoft.com'>continue</a>" & _
"</body></html>"
WebBrowser1.DocumentText = "<html><body>Please enter your name:<br/>" & _
"<input type='text' name='userName' id='userName' value='testUsername'/><br/>" & _
"<a href='http://www.microsoft.com'>continue</a>" & _
"</body></html>"
End Sub
'Fires when the document is loaded completely in browser
Private Sub browser_LoadCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
'Read the entire document
Dim document As System.Windows.Forms.HtmlDocument = _
sender.Document
If document IsNot Nothing And document.All("userName") IsNot Nothing Then
'Access the control Here
Dim UserName As HtmlElement = document.All("userName")
'Read the value
Dim userNameValue As String = UserName.GetAttribute("value")
End If
End Sub