import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.jdom.Attribute;
import org.jdom.Content;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
public class JDOMExample {
public void getXMLData() {
SAXBuilder sbldr = new SAXBuilder();
Document
doc = null;
try {
doc =
sbldr.build(JDOMExample.class.getResourceAsStream("/jdom.xml"));
List lst = doc.getRootElement().getChildren();
for (Iterator iter = lst.iterator(); iter.hasNext();) {
Element element = (Element) iter.next();
List attrlist = element.getAttributes();
for (Iterator iterator = attrlist.iterator();
iterator.hasNext();
) {
System.out.println(
((Attribute) iterator.next()).getValue());
}
List contentlist = element.getContent();
for (Iterator iterator = contentlist.iterator();
iterator.hasNext();
) {
Content contentelement = (Content) iterator.next();
System.out.println(contentelement.getValue());
}
}
} catch (JDOMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Let me know if this helps