<span class="gmail_quote"></span>Hi all. I'm a bit flummoxed by an issue with JDom, which I've been using for about two years now. It appears that Document.getContent is only returning the root element of the document, not all of the elements in the document. For example, here is some test code:
<br><br> private Document d;<br><br> private void parse(){<br> <br> //output the xml to make sure it loaded correctly<br> XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());<br> try {
<br> out.output(d, System.out);<br> } catch (Exception ignored) {}<br> <br> //print out the number of elements returned by getContent<br> System.out.println( d.getContent( ).size() );
<br> <br> //set the ID for this document<br> for ( Object o : d.getContent( ) ) {<br> <br> try {<br> System.out.println(((Element)o).getName());<br> } catch ( ClassCastException ignored ) { }
<br> <br> }<br> <br> }<br><br>The xml document is:<br><br><?xml version="1.0" encoding="UTF-8"?><br><test><br> <a><br> <b><br> <c><br>
<d /><br> </c><br> </b><br> </a><br> <a><br> <b><br> <c><br> <d /><br> </c><br> </b><br> </a><br> <a><br>
<b>
<br> <c><br> <d /><br> </c><br> </b><br> </a><br></test><br><br>And the outcome of this is:<br>[the xml document as shown above]<br>1<br>
test<br><br>So, as you can see, the root element <test> is the one and only element returned in the list returned by d.getContent( ). Can anyone explain why this might be?<br><br>Thanks! Please forgive me if this has been answered previously -- I searched for quite a while and couldn't find a thread with this issue.
<br>