views:

20

answers:

1

I have a web browser control, already navigated to a page. Now I want to search for a specific text in the page, and scroll to the first occurrence.

Being able to scroll to other occurrences is a bonus.

A: 

I don't know if it works in a WebBroswer. We make the broswer(IE/FF/etc) window scroll to some text with the following code:

//source code of http://www.sample.com/sample.html
<html>
...
<span name="aim">KeyWord</span>
...
</html>

If I want the window to scroll to the "KeyWord", simply visit http://www.sample.com/sample.html#aim

Using string document = myWebBrowser.DocumentText to get the source code of the page, and search the text in the string, get its node name, and navigate it using #.

Danny Chen
Actually the problem is not scrolling to a specific node; that has been done. Finding a selection of text that matches the search query is the main problem.
Mostafa Mahdieh
@Mostafa Mahdieh: See my edit.
Danny Chen
I bit of detail must be added here... Searching in the text results in a index in the string. Finding the node that contained that string is not that trivial: The matched text might be the result of multiple text nodes merged into a node.
Mostafa Mahdieh