Click here to Skip to main content
13,145,464 members (90,917 online)
Rate this:
Please Sign up or sign in to vote.
Hi All,

Looking to create a DOM in HTML from aload of HTML.

I currently have a program that is capable of getting the HTML from a website and dumping it into a textbox. from this i was to create a DOM.

Anyone have any ideas... this looks perfect....

HTML DOM Using .NET[^]

However, its C# and won't work in VB.

Posted 22-Feb-13 3:32am
ThePhantomUpvoter 22-Feb-13 9:42am
So compile the C# code to a DLL and use it from your VB code.
Chris Reynolds (UK) 22-Feb-13 9:46am
It should be fairly straightforward to convert the C# into VB, the .NET framework is the same for both so just take it a line or two at a time and you should be OK
ryanb31 22-Feb-13 9:48am
C# and VB.Net are so close that going between generally is not that hard. However, you can try this tool
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you use the WebBrowser Class[^], then you can get the DOM direct from the Document property, which is an instance of the HtmlDocument Class[^].
Member 9829514 22-Feb-13 10:23am
Would you have some sample code please?
Richard MacCutchan 22-Feb-13 10:41am
See my other solution below.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This code gets the HTML from a control that is inherited from WebBrowser, and uses the DOM to find particular tables and items within it.
// logout from 3Rings
HtmlElement element = Document.GetElementById("directory_list");
// get the table header collection (one element)
HtmlElementCollection trCollection = element.GetElementsByTagName("THEAD");
// get the header items collection
trCollection = trCollection[0].GetElementsByTagName("TH");
int xName = -1;
int xEmail = -1;
int nIndex = 0;
foreach (HtmlElement trItem in trCollection)
	string strHeading = trItem.InnerText.Trim().ToLower();
	if (strHeading.Equals("name"))
		xName = nIndex;
	if (strHeading.Equals("email"))
		xEmail = nIndex;

The documentation will offer further examples, or you could search the CodeProject articles for more samples.

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 |
Web04 | 2.8.170915.1 | Last Updated 22 Feb 2013
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