Java tutorial
//package com.java2s; /* * JLib - Publicitas Java library. * * Copyright (c) 2005, 2006, 2007, 2008 Publicitas SA. * Licensed under LGPL (LGPL-LICENSE.txt) license. */ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static int XMLDeep(Node parent) { Node child; NodeList childs; int n; int maxdeep, deep; maxdeep = 0; childs = parent.getChildNodes(); for (n = 0; n < childs.getLength(); n++) { child = (Node) childs.item(n); deep = XMLDeep(child); if (deep > maxdeep) maxdeep = deep; } maxdeep += 1; return maxdeep; } }