<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Highlight words in webbrowser control</title>
	<atom:link href="http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/</link>
	<description>Wrecks of code floating in the sea of Internet By Ricci Gian Maria</description>
	<lastBuildDate>Thu, 09 Feb 2012 16:15:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: FERNANDO LOPEZ</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-3115</link>
		<dc:creator>FERNANDO LOPEZ</dc:creator>
		<pubDate>Tue, 25 May 2010 21:18:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-3115</guid>
		<description>HighLight Results in WebBrowser Control for WPF ...

I nedd to do a little variation of this code to make it works in WPF, here is the code:

1- I need to add the reference: Microsoft.mshtml (solution explorer / Referenes)

2- add using mshtml;

3-  code for the event LoadCompleted (wbContenido = WebBrowser control)

private void wbContenido_LoadCompleted(object sender, NavigationEventArgs e)
        {
            mshtml.HTMLDocumentClass dom = (mshtml.HTMLDocumentClass)wbContenido.Document;
            //Console.Write(dom.body.innerHTML);

            IHTMLDocument2 doc2 = dom;// wbContenido.Document.DomDocument as IHTMLDocument2;
            StringBuilder html = new StringBuilder(doc2.body.outerHTML);

            var words = new[] { &quot;Examen&quot;, &quot;passione&quot; };
            foreach (String key in words)
            {
                String substitution = &quot;&quot; + key + &quot;&quot;;
                html.Replace(key, substitution);
            }

            doc2.body.innerHTML = html.ToString();
        }</description>
		<content:encoded><![CDATA[<p>HighLight Results in WebBrowser Control for WPF &#8230;</p>
<p>I nedd to do a little variation of this code to make it works in WPF, here is the code:</p>
<p>1- I need to add the reference: Microsoft.mshtml (solution explorer / Referenes)</p>
<p>2- add using mshtml;</p>
<p>3-  code for the event LoadCompleted (wbContenido = WebBrowser control)</p>
<p>private void wbContenido_LoadCompleted(object sender, NavigationEventArgs e)<br />
        {<br />
            mshtml.HTMLDocumentClass dom = (mshtml.HTMLDocumentClass)wbContenido.Document;<br />
            //Console.Write(dom.body.innerHTML);</p>
<p>            IHTMLDocument2 doc2 = dom;// wbContenido.Document.DomDocument as IHTMLDocument2;<br />
            StringBuilder html = new StringBuilder(doc2.body.outerHTML);</p>
<p>            var words = new[] { &#8220;Examen&#8221;, &#8220;passione&#8221; };<br />
            foreach (String key in words)<br />
            {<br />
                String substitution = &#8220;&#8221; + key + &#8220;&#8221;;<br />
                html.Replace(key, substitution);<br />
            }</p>
<p>            doc2.body.innerHTML = html.ToString();<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2929</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Mon, 01 Feb 2010 15:41:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2929</guid>
		<description>Doing what you want is just a matter of creating a javascript that is able to do this. But it seems not simple to me. The javascript functino I used was taken from a third party blog. 

Alk.</description>
		<content:encoded><![CDATA[<p>Doing what you want is just a matter of creating a javascript that is able to do this. But it seems not simple to me. The javascript functino I used was taken from a third party blog. </p>
<p>Alk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff T.</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2928</link>
		<dc:creator>Jeff T.</dc:creator>
		<pubDate>Mon, 01 Feb 2010 10:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2928</guid>
		<description>I did your code above and it worked for me. My Question is, can i use outertext instead of outerhtml from the body so that i can highlight those text inside a html tag. like inside an &quot;A&quot; element. Sample is

&quot;This is a &lt;a href=&quot;www.sample.com&quot; rel=&quot;nofollow&quot;&gt; HighLight Me &lt;/a&gt; please sample&quot;.

My search word is &quot;This is a HighLight Me please sample&quot; and this should match the above exampe and ignoring the html element.</description>
		<content:encoded><![CDATA[<p>I did your code above and it worked for me. My Question is, can i use outertext instead of outerhtml from the body so that i can highlight those text inside a html tag. like inside an &#8220;A&#8221; element. Sample is</p>
<p>&#8220;This is a <a href="www.sample.com" rel="nofollow"> HighLight Me </a> please sample&#8221;.</p>
<p>My search word is &#8220;This is a HighLight Me please sample&#8221; and this should match the above exampe and ignoring the html element.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2880</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Sat, 09 Jan 2010 11:41:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2880</guid>
		<description>Converting to VB.Net should not be a difficult task, but I suggest you to use my other approach listed in this post http://www.codewrecks.com/blog/index.php/2009/03/11/hilite-words-in-webbrowser-now-for-wpf-control/ that uses a javascript hiliter. 

Alk.</description>
		<content:encoded><![CDATA[<p>Converting to VB.Net should not be a difficult task, but I suggest you to use my other approach listed in this post <a href="http://www.codewrecks.com/blog/index.php/2009/03/11/hilite-words-in-webbrowser-now-for-wpf-control/" rel="nofollow">http://www.codewrecks.com/blog.....f-control/</a> that uses a javascript hiliter. </p>
<p>Alk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hekmat</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2871</link>
		<dc:creator>Hekmat</dc:creator>
		<pubDate>Thu, 07 Jan 2010 07:20:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2871</guid>
		<description>Please convert this code to vb.net !</description>
		<content:encoded><![CDATA[<p>Please convert this code to vb.net !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2703</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Mon, 05 Oct 2009 22:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2703</guid>
		<description>The problem with this kind of code, is that we manipulate directly the DOM in a very harsh way. As an example that code replaces key even inside tag, and sometimes this completely destroy the html page. The main problem is that you need an html parser to avoid HTML structure corruption.

A better solution I found, as I said before, was switching to an alreaady tested javascript function to hilite text. 

To reverse hiliting the best way is to save the original content of the page, and when you need to remove hilighting you simply reassign old content to the innerHTML property.

alk.</description>
		<content:encoded><![CDATA[<p>The problem with this kind of code, is that we manipulate directly the DOM in a very harsh way. As an example that code replaces key even inside tag, and sometimes this completely destroy the html page. The main problem is that you need an html parser to avoid HTML structure corruption.</p>
<p>A better solution I found, as I said before, was switching to an alreaady tested javascript function to hilite text. </p>
<p>To reverse hiliting the best way is to save the original content of the page, and when you need to remove hilighting you simply reassign old content to the innerHTML property.</p>
<p>alk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alkampfer</title>
		<link>http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/comment-page-1/#comment-2699</link>
		<dc:creator>alkampfer</dc:creator>
		<pubDate>Mon, 05 Oct 2009 12:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codewrecks.com/blog/index.php/2009/02/13/highlight-words-in-webbrowser-control/#comment-2699</guid>
		<description>As soon as possibile I&#039;ll post a working sample, it seems that everything is ok, so I&#039;ll try your code to understand what is wrong.

alk.</description>
		<content:encoded><![CDATA[<p>As soon as possibile I&#8217;ll post a working sample, it seems that everything is ok, so I&#8217;ll try your code to understand what is wrong.</p>
<p>alk.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

