InnerHTML without Id help

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
13 posts Page 2 of 2
Contributors
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: InnerHTML without Id help
mandai
You could check to see if the li tag has any attributes that you are looking for. E.g. you could check the class:
Code: Select all
        For i As Integer = 0 To elements.Count - 1
            If elements(i).GetAttribute("className") = "credits" Then
                Label1.Text = elements(i).InnerText
                Exit For
            End If

        Next
'Note: className is implemented in IE.
You could also get the element of the parent node 'link-bar', then just run GetElementsByTagName("li") from this node, the first sub-element will be the right one.
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Re: InnerHTML without Id help
lesan101
mandai wrote:
You could check to see if the li tag has any attributes that you are looking for. E.g. you could check the class:
Code: Select all
        For i As Integer = 0 To elements.Count - 1
            If elements(i).GetAttribute("className") = "credits" Then
                Label1.Text = elements(i).InnerText
                Exit For
            End If

        Next
'Note: className is implemented in IE.
You could also get the element of the parent node 'link-bar', then just run GetElementsByTagName("li") from this node, the first sub-element will be the right one.

elements isn't declared.

also, what you mean by classname implemented in IE, i use chrome.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: InnerHTML without Id help
mandai
elements is declared in the previous sample.
The className attribute is used to check the class, this is only because in a webbrowser control/IE calling GetAttribute("class") will always return an empty string.
13 posts Page 2 of 2
Return to “Tutorial Requests”