我使用DOM解析器来挖掘数据。问题我无法获得“enclosure”标记中的“url=”“length”和“type”标记
<item>
<title>blah blah</title>
<description>blah blah</description>
<enclosure url="THEURL" length="LENGTH" type="TYPE" />
</item>
下面是我使用的代码:有人能给我指出正确的方向吗?
for (int t = 0; t < nList.getLength(); t++) {
Node nNode = nList.item(t);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
System.out.println("title : "
+ getTagValue("title", eElement));
System.out.println("description : "
+ getTagValue("description", eElement));
for (int t2 = 0; t2 < nList2.getLength(); t2++) {
Node nNode2 = nList2.item(t2);
Element eElement2 = (Element) nNode2;
System.out.println("url: "
+ getTagValue("url", eElement2));
}
}
}
private static String getTagValue(String sTag, Element eElement) {
NodeList nlList = eElement.getElementsByTagName(sTag).item(0)
.getChildNodes();
Node nValue = (Node) nlList.item(0);
return nValue.getNodeValue();
}