Getting html source inside a frame (webbroser control)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":


IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;


foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with a
frameset. Could anyone tell me how to print all "text-tags" from all frames
within the frameset?

Tanks in advance,

Randy
 
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE
 
Thanks a lot!

Randy


DalePres said:
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE


Randy said:
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":


IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;


foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy
 
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy





DalePres said:
You can access the frame documents like this (wb1 is a WebBrowser Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE


Randy said:
Hi,

in C# I'm able to access a webbrowser control with the following code and
print out all "tags":


IHTMLDocument2 HTMLDocument = (IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;


foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy
 
Unfortunately, my current WebBrowser based project is in version 2.0 of the
..Net Framework. The WebBrowser control in version 2.0 does not allow the
Windows.Forms.HtmlDocument object to be cast as IHTMLDocument2 so I can't
duplicate your code and try it out.

The best news is that in version 2.0, the Windows.Forms.HtmlDocument object
has a method GetElementsByTagName which makes what you're trying to do
simple and, in fact, I am using it to do what you're trying to do: read
elements of a specific type from a frame document.

The IHTMLDocument2 doesn't have the same method but the IHTMLDocument3 does.
Of course, IHTMLDocument3 doesn't expose the links property. Perhaps in
combination, you can come up with something that will get you what you want.

DalePres

Randy said:
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy





DalePres said:
You can access the frame documents like this (wb1 is a WebBrowser
Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE


Randy said:
Hi,

in C# I'm able to access a webbrowser control with the following code
and
print out all "tags":


IHTMLDocument2 HTMLDocument =
(IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;


foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page
with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy
 
Thanks a lot!!!

DalePres said:
Unfortunately, my current WebBrowser based project is in version 2.0 of the
..Net Framework. The WebBrowser control in version 2.0 does not allow the
Windows.Forms.HtmlDocument object to be cast as IHTMLDocument2 so I can't
duplicate your code and try it out.

The best news is that in version 2.0, the Windows.Forms.HtmlDocument object
has a method GetElementsByTagName which makes what you're trying to do
simple and, in fact, I am using it to do what you're trying to do: read
elements of a specific type from a frame document.

The IHTMLDocument2 doesn't have the same method but the IHTMLDocument3 does.
Of course, IHTMLDocument3 doesn't expose the links property. Perhaps in
combination, you can come up with something that will get you what you want.

DalePres

Randy said:
Hi again,

and how can I do that with the IHTMLFramesCollection2?

Thanks in advance,

Randy





DalePres said:
You can access the frame documents like this (wb1 is a WebBrowser
Control):

wb1.Document.Window.Frames[intFrameIndexThatIWant].Document.Body

HTH

DalePres
MCAD, MCDBA, MCSE


Hi,

in C# I'm able to access a webbrowser control with the following code
and
print out all "tags":


IHTMLDocument2 HTMLDocument =
(IHTMLDocument2)browser.Document;

IHTMLElementCollection links = HTMLDocument.links;


foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);

}

This works fine for a non-frameset page...But doesn't work for a page
with
a
frameset. Could anyone tell me how to print all "text-tags" from all
frames
within the frameset?

Tanks in advance,

Randy
 
Back
Top