Results 1 to 3 of 3

Thread: How to get text from webbrowser without id

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2014
    Posts
    3

    How to get text from webbrowser without id

    Hi everybody.

    I need to extract text"Su saldo es 912C$" from Label in webbrowser control and pass it to textbox using vb.net 2012


    HTML Code:
    <form action="publicacion.php?op=1&amp;cod=2" method="POST" class="form-horizontal">    
    
        <div class="control-group">
            <label class="control-label"><strong>Su saldo es 912C$ </strong></label>
        </div>
    </form>
    i have tried many ways not i cannot make it work please help me.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,371

    Re: How to get text from webbrowser without id

    Your label has a class name. Iterate through all the HTMLDocument's elements checking which element has a class attribute set to control-label. If you find one in the iteration, then get that element and exit out the loop.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: How to get text from webbrowser without id

    Code:
            Dim tagCollection = WebBrowser1.Document.GetElementsByTagName("DIV")
    
            For Each tagfound As HtmlElement In tagCollection
    
                If tagfound.Children(0).DomElement.className = "control-label" And _
                    tagfound.DomElement.className = "control-group" Then
                    MsgBox(tagfound.OuterText)
                End If
    
            Next tagfound

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width