简体   繁体   English

我将如何使用JSoup在JEditorPane或类似文件上显示文档

[英]How would I use JSoup to display a Document on a JEditorPane or similar

Would I be able to display a JSoup org.jsoup.nodes.Document in a window. 我将能够在窗口中显示JSoup org.jsoup.nodes.Document What I'm doing is taking HTML code from Document doc = Jsoup.connect(URL).get(); 我正在做的是从Document doc = Jsoup.connect(URL).get();获取HTML代码Document doc = Jsoup.connect(URL).get(); and I want to display doc in a window. 我想在一个窗口中显示doc How would I go about doing this? 我将如何去做呢? Also if it is possible, would I be able to style it correctly? 另外,如果可以的话,我可以正确设置样式吗?

JSoup is the wrong API for this purpose. JSoup是错误的API。 It is used to parse HTML content into its document elements. 它用于将HTML内容解析为其文档元素。

JEditorPane has a setPage method for setting content which will also give you the styling for the page: JEditorPane具有用于设置内容的setPage方法,该方法还将为您提供页面样式:

editorPane.setPage(new URL("http://www.mysite.com"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM