我必须走一棵从 NodeList 到达我的树,我需要一个算法来按顺序遍历所有节点,很可能是深入的,但不是如何实现它。我想我需要一些递归。有人可以帮忙吗?
部分代码为:NodeList nodeLista = documento.getElementsByTagName("html");
for (int s = 0; s < nodeLista.getLength(); s++) {
Node Raiz = nodeLista.item(s);
……
for (int h = 0; h < nodeLista.getLength(); h++) {
//Level of depth 1.
Node Primer_Hijo = nodeLista.item(h); // In the first iteration for the HEAD will enter in the second iteration enter the BODY.
//Level of depth 2.
Element SegundoElemento = (Element) Primer_Hijo;
NodeList ListadeNodos2 = SegundoElemento.getChildNodes();
......