Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using the JDOM - how to get List of elements

807603Jan 10 2008 — edited Jan 10 2008
HI,

This may sound like the sort of question which warrants an answer in the form "try reading the javadocs" but the JDOM website is hanging when i try and download the JDOM javadocs so I am in a bit of a bind here and any help much appreciated.

I have an xml document such as :
<template>
<name>My Template</name>
<template_atoms>
     <atom>
          <atom_name>Bob</atom_name>
          <atom_age>23</atom_age>
     </atom>
     <atom>
          <atom_name>Shirley</atom_name>
          <atom_age>54</atom_age>
     </atom>
</template_atoms>
</template>
I need to be able to do two things, given that I have a Document doc:

1. simply get the text between an element like this: String data = doc.getElementText("name").toString() should return "My Template"
2. return a Hashtable or similar collection of all the <atom> elements such that <atom_name> data is used as key and <atom_age>data is the value.

Without the javadoc I am not going to get very far! Thanks for your help
hugh

Edited by: Hacland on Jan 10, 2008 3:04 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 7 2008
Added on Jan 10 2008
1 comment
403 views