如何url = ""
从以下 XML-Tag 中提取部分。我Jsoup
在 Android 中使用 ,。
<enclosure type="image/jpg" url="EXTRACT THIS" length="123456" />
查看我的代码:
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
// Get all <item> tags.
NodeList nl = doc.getElementsByTagName("item");
int length = nl.getLength();
for (int i = 0; i < length; i++) {
Node currentNode = nl.item(i);
RSSItem _item = new RSSItem();
NodeList nchild = currentNode.getChildNodes();
int clength = nchild.getLength();
// Get the required elements from each Item
for (int j = 0; j < clength; j = j + 1) {
Node thisNode = nchild.item(j);
String theString = null;
String nodeName = thisNode.getNodeName();
//NodeList test = nchild.item(j).getChildNodes();
if(j<=3){
theString = nchild.item(j).getFirstChild().getNodeValue();
}
if("enclosure".equals(nodeName)){
//HAVE TO GET URL HERE from ATTRIBUTE:
}
这是 XML:
view-source:http://www.skysports.com/rss/0,20514,11661,00.xml