axWebBrowser, selecting an element and jumping to edit view of HTML



hi,

I have been using the AxWebBrowser control with some success to create
a simple editor where you can right-click over a highlighted HTML
element (e.g. a button) and be taken to the corresponding HTML for that
element.

However, I can only get this to work reliably if the elements have "ID"
attributes AND the whole element is selected.

I cannot think how to get this to work for text selection! I know how
to get the selected text:

IHTMLSelectionObject SelObj = doc1.selection;
IHTMLTxtRange TxtRange = (IHTMLTxtRange)SelObj.createRange();

But I dont want to just do a crummy text search to find this in the
HTML for obvious reasons! I cant get an ID since the text might not be
in a discrete block and of course only part of the block might be
selected...

Can anyone think of a nice way to do this?

thankyou all for any help!

Gav

.