Select span, and pick up the text inside

1

I have the following HTML code:

<div class="dados">

<span><strong>Nome:</strong> Yuri Santos</span>
<span><strong>E-mail:</strong> [email protected]</span>

<span><strong>Endereço:</strong> Rua treze</span>

<span><strong>Cidade:</strong> Dos Sonhos</span>

</div>

And using a WebBrowser I want to get the values that are within a given span .

However, I want to select what are, eg, Name, Email.

I have the following code:

For Each h As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
        If Not Object.ReferenceEquals(h.GetAttribute("className"), Nothing) AndAlso h.GetAttribute("className").Equals("dados") Then
            txtDados.Text = h.InnerText
            Exit For
        End If
   Next

However, it takes all values (name, email, address, city).

As they do not have ID or nome , I do not know how to identify them to get only the ones I want.

    
asked by anonymous 26.07.2015 / 22:48

1 answer

1

Do not use WebBrowser this is a page renderer and you do not need this. Or use WebClient or even better use the HTML Agility Pack library that does this most appropriately.

These tools will help but you have to do a bit of "legwork". What you will have at your disposal is a more organized and easier to filter data structure.

    
26.07.2015 / 23:02