Great -- that's it, thanks! A misunderstanding of the javadoc... get's ya every time. ;-)<br><br><div><span class="gmail_quote">On 3/25/07, <b class="gmail_sendername">Jason Hunter</b> <<a href="mailto:jhunter@servlets.com">
jhunter@servlets.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Julius,<br><br>document.getContent() returns all nodes directly under the document,
<br>which would be the root element and maybe some comments or processing<br>instructions, and maybe a doctype. It's not designed to iterate through<br>the full document. For that you can call document.getDescendants
(). It<br>gives you an iterator for all nodes matching the optional filter you<br>pass it.<br><br>-jh-<br><br>Julius Schorzman wrote:<br>> Hi all. I'm a bit flummoxed by an issue with JDom, which I've been<br>
> using for about two years now. It appears that Document.getContent is<br>> only returning the root element of the document, not all of the elements<br>> 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
<br>> returned in the list returned by d.getContent( ). Can anyone explain<br>> why this might be?<br>><br>> Thanks! Please forgive me if this has been answered previously -- I<br>> searched for quite a while and couldn't find a thread with this issue.
<br>><br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> To control your jdom-interest membership:<br>> <a href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br></blockquote></div><br>