Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2004

Tip: Looking for answers? Try searching our database.

Searching in an HTML document

Thread view: 
Rogan Dawes - 17 Sep 2004 12:34 GMT
Hi,

If I have an HTML document, and want to search for and highlight a
string in the document, is there an easy way of getting from the
character positions in the raw HTML to the corresponding selection point
in a JEditorPane?

e.g. My html is:

<html><head></head><body><h1>header</h1>text</body>

If I search for "header" in the raw html, I get position 29. But in the
JEditor Pane, to highlight it, I need to setCaretPosition(0),
moveCaretPosition(6).

Is there a way of doing this? i.e. working out that the rendered caret
position for an arbitrary html document substring?

Regards

Rogan
Signature

Rogan Dawes

*ALL* messages to discard@dawes.za.net will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"

andreas - 17 Sep 2004 20:41 GMT
> Hi,
>
[quoted text clipped - 13 lines]
> Is there a way of doing this? i.e. working out that the rendered caret
> position for an arbitrary html document substring?

if you only parse text and not html code, maybe
you should parse editorPane.getText() instead of the raw html?
i don't know if this works, it is only a guess...

andreas
Rogan Dawes - 20 Sep 2004 07:55 GMT
>>Hi,
>>
[quoted text clipped - 19 lines]
>
> andreas

Thanks for the suggestion, but this does not work :-(

Rogan

Signature

Rogan Dawes

*ALL* messages to discard@dawes.za.net will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"

Toqwaz - 21 Sep 2004 16:53 GMT
Strip all html tags, this is one of the ways to do that:
String noHTMLString = htmlString.replaceAll("\\<.*?\\>","");


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.