Click here to Skip to main content
13,145,068 members (56,901 online)
Rate this:
Please Sign up or sign in to vote.
hi folks
i have webBrowser1 control on my form
navigating website.
and that website looks like this

<div class="main">
dont interested this div tag
<div class="thin">
<a href="">tbiliso_city</a>,
<a href="">GIZ-888</a>,
<a href="">t-90</a>,
<html> is profile page link and "tbiliso_city" is username;
i want to read all of these links (or usernames) in div tag "thin" and put them in listbox :)
can u help me?

its my work but does not work
HtmlDocument doc = webBrowser1.Document;
            HtmlElementCollection col = doc.GetElementsByTagName("thin");
            foreach (HtmlElement element in col)
                string cls = element.GetAttribute("href");
                HtmlElementCollection childDivs = element.Children.GetElementsByName("thin");
                foreach (HtmlElement childElement in childDivs)
Posted 20-Oct-11 9:04am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First thing which caught my eye is: <div class="thin"> does not define the name of the div element, it defines its CSS style class. Instead, use the attribute name (or both), for example: <div class="thin" name="thin">.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The function "GetElementsByTagName" will get elements by tag name, not by class or ID. You happen to be looking for elements with the tag name "div", so that's what you'd want to pass to that function. You'd then want to check the "class" attribute (you already know how to do that, based on what I see in your code) to see if it equals "thin".
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

thanks i did
thats solution:

HtmlElementCollection a = webBrowser1.Document.GetElementsByTagName("a");
            foreach (HtmlElement b in a)
                if (b.GetAttribute("href").StartsWith(""))
                    string item = b.GetAttribute("href");
                    int indx = item.Length - 26;
                    string retString = item.Substring(26, indx);
                    item = null;
                    retString = null;
boom12345 9-Oct-12 7:01am
HtmlElementCollection a = webBrowser1.Document.GetElementsByTagName("a");i have a error to use a new keyword to create an instance of object...reply plz
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

so try this:
HtmlElementCollection a = new HtmlElementCollection();
a = webBrowser1.Document.GetElementsByTagName("a");
Member 10371894 26-Feb-15 20:57pm
i have a table defined in html page, where i need to get the data from table to list how can i do that..?

here is my design

<table border="0" cellspacing="0" cellpadding="0" width="100%" summary="">
<td align="left" valign="top" class="small">FIDELITY NATIONAL FINANCIAL, INC. <br>   (Y10070072898)</td>
<td align="right" valign="top"><img src="/images/hpweb_1-2_info_icn.gif" border="0" alt="detail for FIDELITY NATIONAL FINANCIAL, INC."></td>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100