开发者

Extracting HTML from Java after execution of Scripts

开发者 https://www.devze.com 2023-04-13 03:46 出处:网络
I have one HTML file, which consist of a UI defenition开发者_如何学C and an XML file with some data, that will be rendered in this UI using script parsing. This is achieved by browser and it\'s render

I have one HTML file, which consist of a UI defenition开发者_如何学C and an XML file with some data, that will be rendered in this UI using script parsing. This is achieved by browser and it's rendering perfectly. Now my question is about any way to do this rendering without a browser, and extract the resulting HTML, with all data values in places, so that I can make a HTML file seperately, that I need for a PDF creation.

Can I do this task from Java? is there any option available?

edit:

I found one simulation library called HtmlUnit from Sourceforge. That renders the HTML properly, and is executing few scripts. The problem is their JavaScript engine is not supporting DOMParser or any XML parsing methods. Any one know a solution to this?


Have you looked at XSLT to do this ?


Using Flying Saucer which is using iText underneath you can convert the html with css into a PDF.

The bit I don't understand is how the HTML and XML get displayed in a browser. Is there a lot of javascript that pulls the xml apart and injects into into the HTML? Is there some library that is doing some template processing?

-edit-

I was afraid that you were using javascript to populate the page. I am just offering suggestions because I'm really not sure how to procede.

Cobra looks like it is a library that can handle html and javascript. It seems like it is only supporting html4 at the moment and I don't know if you can supply all of the input and have it produce an output stream that you could then provide to Flying Saucer.

You may have to take a step back and create a specific page that gets populated by the xml data for this purpose.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号