• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTML Tag problem  RSS feed

 
sreejith panampilly
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am retriving some text content from database..
it contains the HTML tags like <FONT face=Tahoma size=2>HAPPY INDEPENDENCE DAY</FONT>

Is any method avilable in java to filter this HTML tags?


Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "filter"?
 
Vijayender Bandaru
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By filter,you mean to remove the complete HTML tags? In that case if you always have a string of following pattern



then you can use substring method on this string like this.

[ August 03, 2007: Message edited by: Vijayender R. Bandaru ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's fairly risky trying to manipulate HTML as a String that way. HTML is often badly formed and you might pick up stray < and > characters in the text.

The HTMLEditorKit in the library has an HTML parser. You can Google for other parsers, too. I used to use an older version of the Quiotix parser. Parsers might have trouble with your small fragments if they're looking for html and body tags and such, or they might work just fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!