[jdom-interest] newbie question

Sylvain.Thevoz at swisscom.com Sylvain.Thevoz at swisscom.com
Wed Dec 4 05:04:39 PST 2002


I'm trying to use JDOM instead of DOM because I think it's a very interesting work to make XML stuffs easier.

But there is something that I don't understand (or maybe I have a wrong code):

I have this XML file:
    <item id="desktop">
    <item id="laptop">
    <item id="other">
      <description>Other configuration</description>

Now I want to load this file in a JDOM document:
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new File("files\\myfile.xml"));


1) Then I want to get the content of this document. I use the getContent() method:
List docContent = document.getContent();
ListIterator iterator = docContent.listIterator();
while (iterator.hasNext()) {
  Element elements = (Element) iterator.next();
 => it returns only: [Element: <document/>]

Am I in the right way??
I would like to see all XML tree.

How do you do if you want to display all contents of the <description> tags?

Thank you

More information about the jdom-interest mailing list