aspose file tools*
The moose likes Servlets and the fly likes HTML Parsing Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTML Parsing Issue" Watch "HTML Parsing Issue" New topic
Author

HTML Parsing Issue

sudhanshu jain
Greenhorn

Joined: Jan 16, 2008
Posts: 2
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

Joined: Dec 11, 2004
Posts: 13410

This is exactly what JSP is for.
Why are you building HTML in Java classes?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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

Joined: Jan 16, 2008
Posts: 2
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

Joined: Mar 22, 2000
Posts: 12769
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTML Parsing Issue