Re: select a specified text within some element?



<gmclee@xxxxxxxx> wrote in message
news:1151855996.620284.7460@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi there,
How can I select a given text within a specified element with an
unique id? For example,
I would like to select the text "Hello! The world" which is enclosed
with

<span id="a special id">Hello! The world</span>

I tried the following code

txtRange.FindText("Hello! The world", 0, 0);
txtRange.Select;

The code works sometimes when there is not duplicate text "Hello! The
world" in the whole souce code.

Use TextRange.moveToElementText and collapse first, then findText will
start its search from the beginning of your element. In fact, in your
example you don't need findText at all, moveToElementText would suffice.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.