HTML 解析和生成器 Cobra
<p>Cobra 是一个纯 Java 的HTML 解析和生成器,支持 HTML 4 、JavaScript、CSS 2</p> <p>示例代码:</p> <pre class="brush:java; toolbar: true; auto-links: false;">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);</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324371050796" target="_blank">http://www.open-open.com/lib/view/home/1324371050796</a></p> <p></p>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!