【发布时间】:2017-06-24 22:45:50
【问题描述】:
我写了一个方法来插入一个带有作为参数传递的文本的 div。 然后我注意到我需要在该 div 中添加各种 HTML 内容。当前方法适用于以下基本的 5 行指令:
//engine is the WebEngine object of some WebView object
Node html = engine.getDocument().getChildNodes().item(0);
Node body = html.getChildNodes().item(1);
Element e = engine.getDocument().createElement("div");
e.setTextContent(msg);
body.appendChild(e);
所以我的问题来了。有没有办法将一些 HTML 内容解析为 Element 对象,以便我可以将该元素附加到文档中?
示例 HTML 字符串:<b>SomeText</b>
【问题讨论】:
-
你可以看看JSoup是否有你要找的东西。