0

I just create a HTML document on Java using Jsoup. below is some part of the code

public static Document genDoc(String p) throws ProtocolException, IOException, InterruptedException, ParserConfigurationException{
   ........
   return Jsoup.parseBodyFragment(html);
}

After I'm done with the document generation, I have to display it. I simply use XHTML panel from FlyingSaucer. This is the code

public static void main(String[] args) throws ProtocolException, IOException, InterruptedException, ParserConfigurationException{
   Document doc = genDoc("http://www.mangareader.net/93-1-11/naruto/chapter-1.html");
   XHTMLPanel xhp = new XHTMLPanel();
   xhp.setDocument(doc);
   ........
}

I thought the class org.jsoup.nodes.Document inherited from ´org.w3c.dom.Document´. But I was wrong. Is there any way I can pass the object of ´org.jsoup.nodes.Document´ to generate a web view using XHTMLPanel without converting it to string or input stream or byte[] first?

DanielK
  • 424
  • 6
  • 17
stackunderflow
  • 1,492
  • 1
  • 23
  • 53

1 Answers1

0

I guess there's no way around Strings, since both Libs usings differnent implementations of Document.

Maybe you can write a converter for jsoup <-> w3c, but the most simple way is using Strings.

In your case xhp.setDocument(doc.toString()); should work without any problem.

(I'm using this for eg. HTML -> PDF generation, no problems so far)

ollo
  • 24,797
  • 14
  • 106
  • 155