Leitura arquivo.xml com jdom

0 respostas
L
ARQUIVO.XML
<?xml version="1.0" encoding="UTF-8"?>
<Agenda>
    <contato>
        <nome>Joao Paulo</nome>
        <telefone>342424323</telefone>
        <endereco>rua teste</endereco>
        <email>[email removido]</email>
		<habilidades>
			<box1>
				<força>maxima</força>
				<braco>33</braco>
			</box1>
			<box2>
				<força>media</força>
				<braco>40</braco>
			</bo21>
		</habilidades>
    </contato>
</Agenda>

MEU PROBLEMA ESTA NA LEITURA DE HABILIDADES NAO CONSIGO LER ESTOU USANDO JDOM COM O EXEMPLO ..:

public class Elemento {

    private List<Bean> listaBean;
    private List<AtosPraticados> listaAtosPraticados;

    public List<Bean> getElmento(String nomeArquivo) throws IOException {
        try {
            File file = new File(nomeArquivo);
            //processar o arquivo xml
            SAXBuilder saxBuilder = new SAXBuilder();

            //agora document possui estrutura de um arquivo
            Document document;

            document = saxBuilder.build(file);

            //recupera os elementos
            Element element = document.getRootElement();

            List elements = element.getChildren();

            Iterator iterator = elements.iterator();

            listaBean = new ArrayList<Bean>();
            listaAtosPraticados = new ArrayList<AtosPraticados>();

            while (iterator.hasNext()) {


                Element elemento = (Element) iterator.next();

                
                Bean bean = new Bean();
                bean.setEmail(elemento.getChildText("nome"));
                bean.setEndereco(elemento.getChildText("email"));
                bean.setNome(elemento.getChildText("endereco"));
                bean.setTelefone(elemento.getChildText("telefone"));
                setar as habilidades como eu trago box1 e box2 pode ser ate mais...!
                
                listaBean.add(bean);
            }
        } catch (JDOMException ex) {
            Logger.getLogger(Elemento.class.getName()).log(Level.SEVERE, null, ex);
        }
        return listaBean;
    }
}
public static void start(String arquivo) throws IOException {
        Elemento elemento = new Elemento();
        List<Bean> lista = elemento.getElmento(arquivo);
        StringBuffer sb = new StringBuffer("");

        for (Bean b : lista) {
            sb.append(b.getAtos_praticados());
        }
        JOptionPane.showMessageDialog(null, sb);
    }
Criado 6 de maio de 2013
Respostas 0
Participantes 1