Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Retrieve the textual or HTML text contained in a WebBrowser control

Total Hit ( 3853)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Here's a quick way to retrieve the textual (that is, without any HTML tag) contents of a WebBrowser control:

Click here to copy the following block
Dim Text As String
Text = WebBrowser1.Document.Body.InnerText

Getting the HTML text is a tad less intuitive, though:

Click here to copy the following block
Dim Text As String
Text = WebBrowser1.Document.documentElement.OuterHTML

The following procedure let's you save the contents of a WebBroser control to a file, as plain text or HTML text:

Click here to copy the following block
Sub SaveWebBrowser(WB As WebBrowser, ByVal FileName As String, _
  Optional SaveAsPlainText As Boolean)
  Dim Text As String, fnum As Integer

  If SaveAsPlainText Then
    Text = BW.Document.Body.innerHTML
  Else
    Text = BW.Document.documentElement.OuterHTML
  End If

  ' save to file
  fnum = FreeFile
  Open FileName For Output As #fnum
  Print #fnum, Text;
  Close #fnum
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.