我有一根绳子:
String HTMLtag="<xml><xslt><xhtml><whitespace><line-breaks>";我想得到5个字符串: xml、xslt、xhtml、空格和换行。
发布于 2015-03-05 10:50:57
就像这样
String html = "<xml><xslt><xhtml><whitespace><line-breaks>";
Document doc = Jsoup.parse(html, "", Parser.xmlParser());
for (Element e : doc.getAllElements()) {
System.out.println(e.tagName());
}Ouput
#root --> This is the root element that is created by jsoup, you can ignore it.
xml
xslt
xhtml
whitespace
line-breaks编辑
String html = "<xml><xslt><xhtml><whitespace><line-breaks>";
Document doc = Jsoup.parse(html, "", Parser.xmlParser());
for (Element e : doc.getAllElements()) {
String tag = e.tagName();
if(!tag.equalsIgnoreCase("#root"))
System.out.println(tag);
}https://stackoverflow.com/questions/28874463
复制相似问题