Tag selection from web page

GaryAFromOz

New member
Joined
May 20, 2012
Messages
4
Programming Experience
10+
I want to retrieve all input, select and textarea fields only and possibly change their data value. I currently declare as:

Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.All ' which I then iterate through and select on tag name.

I would like to be more efficient and do something like:
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input", "select", "textarea")

but GetElementsByTagName doesn't appear to support multiple selections. I saw on the net where someone declared as:
Dim Tags As HtmlNodeCollection = docNode.SelectNodes("//input | //select | //textarea")

I tried this but HTMLNodeCollection is not referenceable under HtmlDocument. I have played around a bit and can't see an equivalent. Can anyone assist?
 
aw nooo don't goo, we'll miss youu!

look man, getting views and getting answers have nothing to do with each other. Maybe no one here knows the answer to your question. We're programmers but we're also humans. We don't know everything! And if you talk **** and whine like a crybaby on the internet, you won't get help anywhere!
 
You can use a Linq query to get multiple results from a single iteration, for example:
        Dim tags = {"IMG", "A"}
        Dim selection = From el In Me.WebBrowser1.Document.All.OfType(Of HtmlElement)() Where tags.Contains(el.TagName)

        For Each el In selection
            '...
 
Back
Top