tags:

views:

41

answers:

1

I've created a webbrowser in C# and I want to be able to select part of the web page and have the source appear in a text box. So far all I've managed to do is get the whole page's source using:

private void btnSource_Click(object sender, EventArgs e) { string PageSource; mshtml.HTMLDocument objHtmlDoc = (mshtml.HTMLDocument)webBrowser1.Document.DomDocument; PageSource = objHtmlDoc.documentElement.innerHTML; rTBSource.Text = PageSource; } This is way more information than I need. I'm only looking for one small part of the page at a time.

Using the string.contains method will be problematic because the text on the web page contains a number of super-scripted characters. Normal copying and pasting turns the super-scripted characters into regular characters that I cannot get rid of via regexp.

If I can work with the source, I would have better luck getting the a and other tags eliminated.

Any suggestions?

Compiler: C# 2010 express App: WinForm OS: XP sp3

A: 

try this

HtmlElementCollection elm = webBrowser1.Document.Body.All;

in elm you will have all the elements of the body of the webpage and you can get the text of the third element for examole like this

elm[2].innerhtml
Bass
So did it work?, is that what you're looking for?
Bass
I have gotten that to give me access to lines. I need to build an array of sorts to be able to isolate the lines in particular that I am looking for. But yes this gave me the starting point that I needed. I have started to rebuild a whole new interface around this to isolate the lines I am looking for and strip the tags and other extraneous characters. Thanks Bass.
Kyle Seidlitz