日期:2014-05-20 浏览次数:20696 次
for (int i = 0; i < Lengthofnodelist; i++) { Node node = nodeList.item(i); if (node instanceof Element) // whether is it the Element { Element element = (Element) node; // change to the Element jta.append("\n" + element.getTagName() + " ID: " "\n"); NodeList nodeList2 = node.getChildNodes(); int Lengthofnodelist2 = nodeList2.getLength(); int NumofURLs = (Lengthofnodelist2-1)/2; TotalURLs=TotalURLs + NumofURLs; for (int j = 0; j < Lengthofnodelist2; j++) { Node node2 = nodeList2.item(j); if (node2 instanceof Element) { Element element2 = (Element) node2; String t = element2.getAttribute("type");}//得到类型 ;
<session id="aaa" > <request timestamp="2012-7-19 02:01:08" type="item"> <url> /aaaaaaaa.html</url> </request> <request timestamp="2012-6-19 06:02:50" type="page"> <url>/bbbbbb.html</url> </request> </session> <session id="ccc" > <request timestamp="2012-7-19 02:01:08" type="item"> <url> /aaaaaaaa.html</url> </request> <request timestamp="2012-6-19 06:02:50" type="page"> <url>/bbbbbb.html</url> </request> <request timestamp="2012-6-19 06:02:50" type="page"> <url>/ccccc.html</url> </request> </session>