[jdom-interest] newbie question

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


Hello,

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:
<document>
  <typeOfWorkstation>
    <item id="desktop">
      <description>Desktop</description>
    </item>
    <item id="laptop">
      <description>Laptop</description>
    </item>
    <item id="other">
      <description>Other configuration</description>
    </item>
  </typeOfWorkstation>
</document>

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

OK!

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();
  System.out.println(elements);
}
 => 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
Sylvain




More information about the jdom-interest mailing list