none
How to get a node value from webpage? RRS feed

  • Question

  • Hello every one,

    i want to get text form node in html this is the page source

    <div class="res-room-title__name"><span class="res-room-title__number bui-badge bui-badge--outline">
          1
        </span>
    
        Standard Room
        <!----> <!----> <!----> <!----></div>

    and this is the code iam using iam get only 1 but i want to get  Standard Room

    For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
                If Element.GetAttribute("className") = "res-room-title__name" Then
                    For Each Element1 As HtmlElement In Element.GetElementsByTagName("span")
                        If Element1.GetAttribute("text") = "res-room-title__number bui-badge bui-badge--outline" Then
                            Dim Variable1 As String = Element1.InnerText
                            Lballrooms.Items.Add(Element1.InnerText)
                        End If
                    Next
                End If
            Next

    and i also check the properties from chrome to this class

    1. innerText"1 Standard Room"
    2. outerText"1 Standard Room"

    Sunday, February 2, 2020 10:11 PM

Answers

  • I figured it out

     For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
                If Element.GetAttribute("className") = "res-room-title" Then
                    For Each Element1 As HtmlElement In Element.GetElementsByTagName("div")
                        If Element1.GetAttribute("className") = "res-room-title__name" Then
                            Dim Variable1 As String = Element1.InnerText
                            Lballrooms.Items.Add(Element1.InnerText)
                        End If
                    Next
                End If
            Next

    Thanks all

    Monday, February 3, 2020 12:10 PM