Here’s the example.
webBrowser1.Document.Body.InnerHtml contains:
<img id="image1" src="myImage.gif">
and in my MyWebBrowser class I want to replate whole img tag to some text, for example to string: “<myImage>” (I need it for my chat application, if user doesn’t want to see images)
I thought I could do something like that:
Document.GetElementById("image1").InnerHtml = "<" + Document.GetElementById("image1").GetAttribute("src") + ">";
but it throws exception.
Actually I resolved that by searching those specific tags in whole document and replacing it using String class’ methods, but code doesn’t look good. If there’s more effective way to do that, do not bother answering my question.
You can use the OuterHtml property:
Note, however, that assigning to
OuterHtmlwill invalidate the reference to the element, soimagewill not refer to the new content afterwards.