Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

Thanks.
Posted
Comments
[no name] 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
ZurdoDev 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 http://www.carlosag.net/tools/codetranslator/

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[^].
 
Share this answer
 
Comments
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.
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.
C#
// 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)
{
	Debug.WriteLine(trItem.InnerText);
	string strHeading = trItem.InnerText.Trim().ToLower();
	if (strHeading.Equals("name"))
		xName = nIndex;
	if (strHeading.Equals("email"))
		xEmail = nIndex;
	nIndex++;
}

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

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