【发布时间】:2011-10-09 10:05:59
【问题描述】:
是否可以使用某种 HTML 解析器,通过它我可以选择要在哪个标签下显示的信息,然后清除所有其他信息?
我尝试使用 Jsoup。为安卓开发。 durig selection 我的应用程序由于“outofmemmoryerror”而崩溃
【问题讨论】:
-
哪个解析器能够做到这一点?
标签: java android tags html-parsing
是否可以使用某种 HTML 解析器,通过它我可以选择要在哪个标签下显示的信息,然后清除所有其他信息?
我尝试使用 Jsoup。为安卓开发。 durig selection 我的应用程序由于“outofmemmoryerror”而崩溃
【问题讨论】:
标签: java android tags html-parsing
您可以使用JSoup 提取标签的一部分并将其分离出来
例如:
String html = "<p>An <a href='http://example.com/'><b>example</b></a> link.</p>";
Document doc = Jsoup.parse(html);
Element link = doc.select("a").first();
String text = doc.body().text(); // "An example link" , and ignore the rest
【讨论】: