Hello. I am trying to get children to printout for my elements.
Could someone tell me how my class should approach this procedure?

My class is suposed to find a certain element name, then from that find the element with the specific attribute and from that element with the specific attribute list the children. Is that possible?


<?xml version="1.0" encoding="utf-8" ?>
    <keyName keyname="cmaj">
      <![CDATA[C Major]]>
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
package keycards;

 * @author depot

import keycards.KeyCards;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;

import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.xml.sax.SAXException;

public class XMLReaderProgressions extends KeyCards {

    public Progression p;
    private String name;
    public Document doc;
    public Element e;
    public int count = 0;
    public int childCount = 0;
//experimenting with jdom when the combox is clicked

    public XMLReaderProgressions() {

    public void readAll(String name) throws ParserConfigurationException, SAXException, IOException {
        this.name = name;
        SAXBuilder builder = new SAXBuilder();
            Document doc = null;
        try {
            doc = (Document) builder.build(file);
        } catch (JDOMException ex) {


    public void listElements(Element e) {
        List c = e.getChildren();
        for (Iterator i = c.iterator(); i.hasNext();) {
            Element n = (Element) i.next();
                List attr=n.getAttributes();
                for(Iterator it =attr.iterator();it.hasNext();){
                    Attribute a = (Attribute) it.next();
                        System.out.println("element: "+n.getName());
                        List ec=n.getChildren("keyName");
                        int s=ec.size();
                        System.out.println("there is: "+s+" in the ec list"+
                                " childElements:");
                        Iterator x=ec.iterator();
                            Element keyName=(Element)i.next();
                            System.out.println("\t "+ keyName.getChildren());



    public void listChildElements(Element x) {
System.out.println("In ListChildren");
        List c = x.getChildren();
        childCount = c.size();
        System.out.println("Found something: " + childCount);
        for (Iterator i = c.iterator(); i.hasNext();) {
            Element n = (Element) i.next();
    }//end listChildElements()

    public String getName() {
        return name;

    public void setName(String name) {
        this.name = name;