Rectangle 27 0

How to parse and modify HTML file in Java?


I am using Xalan processor currently and the code is working beautifully. Here is the link for the processor xml.apache.org/xalan-j

I guess this was what I was looking forward to. I need to generate reports and present it in the format the user would like it to be presented.

if you want to modify web page and return modified content, I thnk the best way is to use XSL transformation.http://en.wikipedia.org/wiki/XSLT

Note
Rectangle 27 0

How to parse and modify HTML file in Java?


I am using Xalan processor currently and the code is working beautifully. Here is the link for the processor xml.apache.org/xalan-j

I guess this was what I was looking forward to. I need to generate reports and present it in the format the user would like it to be presented.

if you want to modify web page and return modified content, I thnk the best way is to use XSL transformation.http://en.wikipedia.org/wiki/XSLT

Note
Rectangle 27 0

How to parse and modify HTML file in Java?


Check out http://jsoup.org, it has a friendly dom-like API, for simple tasks you don't need to parse the html.

Note
Rectangle 27 0

How to parse and modify HTML file in Java?


If the html files you are working with are well formed (xhtml) then you can also use XML libraries in java to find particular tags and modify them. The IO itself should be handled by the particular libraries you are using.

If you choose to manually parse the strings you could use regular expressions to find particular tags and use the java io libraries to write to the files and create new html documents. But this method reinvents the wheel so to speak because you have to manage tag opening and closing and all of those things are handled by pre-existing libraries.

Look at http://java-source.net/open-source/html-parsers for a list of java libraries that parse html files into java objects that can be manipulated.

Note
Rectangle 27 0

How to parse and modify HTML file in Java?


I used both JTidy and Nekohtml - both are pretty good.

I usually prefer parsing XHTML with the standard Java XML Parsers, but you can't do this for any type of HTML.

Note