• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

HTML Tag problem

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "filter"?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic