publicclasstest{publicstaticvoidmain(String[]args){testt=newtest();Stringxml=""+""+"PNCCAR"+"TT051601"+"
public class test {
public static void main(String[] args) {
test t = new test();
String xml = " " + "" + "PNCCAR"
+ "TT051601" + ""
+ ""
+ ""
+ "" + ""
+ "" + "" + "" + "
"+ "";
t.ttt(xml);
}
public void ttt(String xml) {
Document documentxml = null;
SAXReader reader = new SAXReader();
try {
documentxml = reader.read(new ByteArrayInputStream(new String(xml
.getBytes("UTF-8"), "UTF-8").getBytes("UTF-8")));
} catch (Exception e1) {
e1.printStackTrace();
}
List list = new ArrayList();
list = documentxml.selectNodes("//META_DATA");// 获取多个meta_data
for (int pm = 0; pm < list.size(); pm++) {
Element MetaDate = (Element) list.get(pm);
Element TREE = (Element) MetaDate
.selectSingleNode("TREE_NODE/TREE");
String reid = aaa(TREE);
System.out.println("=" + reid);
}
}
public String aaa(Element TREE) {
String retID = null;
if (TREE.selectSingleNode("TREE") != null
&& !"".equals(TREE.selectSingleNode("TREE"))) {
TREE = (Element) TREE.selectSingleNode("TREE");
aaa(TREE);
} else {
retID = TREE.attributeValue("id");
}
return retID;
}
}
代码走到aaa方法中,自动重调,直到没有节点为止。但实际情况是debug跟走到aaa,重调最后走return,下一步后又返回aaa方法体内aaa(TREE);行了。请问为啥?
展开