• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTML Parsing Issue

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Actually I have a response string containing html data. I want to parse this string and replace the body tag with some attributes. I know with the help of String Buffer it is easy task, but I want to know can we replace this tag through html parser (Swing html parser).

By the help swing html parser I am able to add the tag in html but not able to remove it
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is exactly what JSP is for.
Why are you building HTML in Java classes?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

replace this tag through html parser (Swing html parser).



This is completely the wrong approach - Swing is for desktop applications with a single user. There are many toolkits for combining HTML template text with variable data, with JSP being the most widely used. Do a google search for "java servlet template" to find more.

Bill
 
sudhanshu jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Actually I have to trace the hit through webtrends at response time.
I have a response html string and i want to parse that html response string add some meta -tags which is trace by sdc server.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two possibilities occur to me:
1. If you really need to parse the HTML into tags and content, look into the JTidy toolkit.
2. If you just need to locate certain tags and grab the text between them, use the Java standard library regular expression capabilities. Here is Sun's tutorial on regular expressions.

Bill
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic