I want to parse a xml document using Jdom and then display the resulting tree . Below I have a sample XML, the code in the jsp page, as well as what is outputted. The nested loop is not working correctly. It's nesting over the parent <TestFamily> tag and displaying all <Test#> tags. Any suggestions on the nested loops would be great. I've actually got more nested elements under the <Test> tags, but left them out for now. Also, the JSP isn't very clean. Any suggestions on cleaning it up?
------------------------------------------------Example XML
:----------------------------------------------
<testIndex>
<TestFamily1> <Test1 /> <Test2 /> <Test3 /> </TestFamily1> <TestFamily2> <Test4 /> <Test5 /> </TestFamily2> </testIndex> ------------------------------------------------Code in jsp
page:----------------------------------------------
<% test.TestConfigBean testbean = new
test.TestConfigBean();
java.util.List testfamilylist =
testbean.getTestFamily(testbean.getTestIndexElement());
pageContext.setAttribute("j_tflist",testfamilylist, PageContext.PAGE_SCOPE); %>
<logic:iterate id="testfamily" name="j_tflist"> <bean:write name="testfamily"/><br> <% java.util.Iterator i_tf = testfamilylist.iterator(); while (i_tf.hasNext()) { org.jdom.Element _testType = (Element) i_tf.next(); java.util.List ttype = testbean.getTestArgs (_testType); pageContext.setAttribute("j_ttlist",ttype, PageContext.PAGE_SCOPE); %> <logic:iterate id="testtype" name="j_ttlist"> <bean:write name="testtype"/><br> </logic:iterate> <% } %> </logic:iterate> ------------------------------------------------Resulting
display:----------------------------------------------
[Element:
<TestFamily1/>]
[Element: <Test1/>] [Element: <Test2/>] [Element: <Test3/>] [Element: <Test4/>] [Element: <Test5/>] [Element: <TestFamily2/>] [Element: <Test1/>] [Element: <Test2/>] [Element: <Test3/>] [Element: <Test4/>] [Element: <Test5/>] Thanks,
Blaine Kendall
|