如何在没有 div 的情况下使用 jsoup 解析 android studio 中的 ul 、 li 标签并将其显示在回收站视图中?

普加帕奇加尔

我正在尝试从网页中检索数据,示例 html 代码如下所示 我想检索数据并将其显示在列表视图中。

<html>
 <head> 
  <title>Index of /abc/xyz/Female/pqr</title> 
 </head> 
 <body> 
  <h1>Index of /abc/xyz/Female/pqr</h1> 
  <ul>
   <li><a href="//abc/xyz/Female/pqr"> Parent Directory</a></li> 
   <li><a href="2016060500004.png"> 2016060500004.png</a></li> 
   <li><a href="2016060500011.png"> 2016060500011.png</a></li> 
   <li><a href="2016060500012.png"> 2016060500012.png</a></li> 
</ul>  
 </body>
</html>
巴德兰

要选择 ul 使用这个:

Document doc = Jsoup.parse(input, "UTF-8", "http://example.com/");

Elements ul = doc.select("ul"); // select ul 

请参阅此处的文档:Jsoup 文档

例子 :

String html = "<html>"+
"<head>"+
"<title>Index of /abc/xyz/Female/pqr</title>"+
"</head>"+
"<body>"+
"<h1>Index of /abc/xyz/Female/pqr</h1>"+
"<ul>" +
"<li><a href=\"//abc/xyz/Female/pqr\"> Parent Directory</a></li>"+
"<li><a href=\"2016060500004.png\"> 2016060500004.png</a></li>"+
"<li><a href=\"2016060500011.png\"> 2016060500011.png</a></li>"+
"<li><a href=\"2016060500012.png\"> 2016060500012.png</a></li>"+
"</ul>" +
"</body>"+
"</html>";

Document doc = Jsoup.parse(html);

Elements links = doc.select("ul"); // select ul

for(Element b : links){
    System.out.println(b.text());
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档