Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How to retrieve the data from particulre of html table using vb.net???????? I opened one webpage in webbrowser control which contains the table now i want to retrive the data of that table....and want to stored the data of that table in array.....that table contains numeric values like 1 in first cell,2 in second cell.....and so on up to 20......it has only one row....
Posted
Updated 19-Oct-11 1:11am
v2
Comments
Prerak Patel 19-Oct-11 5:45am    
Not enough information. Elaborate more.
Ankur\m/ 19-Oct-11 7:49am    
[moved from direct comment]
OP wrote:
Hi...Mr.prerak my que. is elaborated now...pls tell me if u want more info.....thankx:)
Ankur\m/ 19-Oct-11 7:48am    
You should use the reply link to reply to a comment. Adding a comment below will not notified the parent commenter, so may not never know what you wanted to say.
I am moving the comment for you.
NikulDarji 19-Oct-11 8:47am    
Oh....thankx I didn,t know that...thankx

First you need to get the actual HTML of the page, I've never used any WebBrowser control so I don't know if they make it easy by providing a property or not, and as I don't know what UI framework you're using I won't spend time on looking it up, but I'm sure you can figure that out yourself.

Once you have the HTML you need to parse/scrape it, so you have to look for a pattern you can search for in the HTML-string if there is only one table that pattern could be "<table" once you've found the start of the table you just find the "<td" and take all text between ">" and "</" and you repeat that until you hit "</table>"
 
Share this answer
 
Comments
Espen Harlinn 20-Oct-11 5:23am    
That's one way to do it :)
Simon Bang Terkildsen 20-Oct-11 7:30am    
Yeah, personally I would use Regex, but that would have been far to long an answer if I had to involve that.
You can access and manipulate the page using the WebBrowser.Document[^] property. The HtmlDocument.GetElementById[^] would probably allow you to access the table more or less directly.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Simon Bang Terkildsen 20-Oct-11 7:39am    
Nice that's really simple, though it will only work if there actually is an id :).
Espen Harlinn 20-Oct-11 13:49pm    
Thanks Simon, if there is no id, he will have to traverse the dom :)
Simon Bang Terkildsen 20-Oct-11 17:15pm    
Seems like such a hassle to me, much simpler with regular expressions, if one knows regex that is :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900