• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML Parsing Issue

 
sudhanshu jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is exactly what JSP is for.
Why are you building HTML in Java classes?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic