JDOM - finding a nested CHILD ELEMENT
Posted on 2002-06-26
Hi, I need help creating a loop that will find a child element ANYWHERE in the JDOM Document. For instance, my document is as follows:
<E1A>TEXT AND SUCH</E1A>
To find a first-level child is easy: ROOT.getChild("E1"); However, to find a nested child (E1B1 for instance) you need a loop to look through the root element for E1B1, if we dont find it there, look through all of the second level elements (E1A and E1B), and so on until either we reach the end of the structure or we find the element E1B1. I need this loop to be generic, that is, it will work for ANY JDOM XML Document structure, with and number of levels and elements. This is a brain teaser (at least for me) I am sick of racking my brain on the loop code - I am not a pro Java developer...yet. Thanks to all who try to answer this question!
EMAIL ME WITH *ANY* QUESTIONS!