HTML 解析和生成器 Cobra
Cobra 是一個純 Java 的HTML 解析和生成器,支持 HTML 4 、JavaScript、CSS 2
示例代碼:
import org.lobobrowser.html.parser.*; import org.lobobrowser.html.test.*; import org.lobobrowser.html.gui.*; import org.lobobrowser.html.*; import org.w3c.dom.*; ... HtmlPanel panel = new HtmlPanel(); // This panel should be added to a JFrame or // another Swing component. UserAgentcontext ucontext = new SimpleUserAgentContext(); SimpleHtmlRendererContext rcontext = new SimpleHtmlRendererContext(panel, ucontext); // Note that document builder should receive both contexts. DocumentBuilderImpl dbi = new DocumentBuilderImpl(ucontext, rcontext); // A documentURI should be provided to resolve relative URIs. Document document = dbi.parse(new InputSourceImpl(documentReader, documentURI)); // Now set document in panel. This is what causes the document to render. panel.setDocument(document, rcontext);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!