Ler Arquivo XML utilizando JDOM com + de 1 registro

Eu tenho um XML que tem essa estrutura:

<?xml version="1.0" encoding="UTF-8"?> 11 2012 D ORCADO GENER-M-00084 INSTI GENER-I-00001 Indicador de Teste 1 3 5 7 9 11 13 15 17 19 21 23 GENER-I-00002 Teste Indicador II 2 4 6 8 10 12 14 16 18 20 22 24 Eu estou utilizando este código: public void LerXML(String mes, String ano, String codigo, String ambiente, String tipo) throws JDOMException { String nome_mapa = "c:/logs/mapa_" + codigo + "_" + ano + mes + "_" + tipo + ".xml"; File arquivo = new File(nome_mapa); SAXBuilder builder = new SAXBuilder(); try { Document doc = builder.build(arquivo); Element mapas = (Element)doc.getRootElement(); List mapa = mapas.getChildren(); Iterator m = mapa.iterator(); while (m.hasNext()) { Element map = (Element) m.next(); System.out.println("GeraMapaXML - LerXML - MES_REF: " + map.getChildText("MES_REF")); System.out.println("GeraMapaXML - LerXML - ANO_REF: " + map.getChildText("ANO_REF")); System.out.println("GeraMapaXML - LerXML - FLG_AMBIENTE: " + map.getChildText("MES_REF")); System.out.println("GeraMapaXML - LerXML - COD_MAPA: " + map.getChildText("COD_MAPA")); System.out.println("GeraMapaXML - LerXML - DSC_MAPA: " + map.getChildText("DSC_MAPA")); System.out.println("GeraMapaXML - LerXML - COD_INDICADOR: " + map.getChild("INDICADOR").getChildText("COD_INDICADOR")); System.out.println("GeraMapaXML - LerXML - DSC_INDICADOR: " + map.getChild("INDICADOR").getChildText("DSC_INDICADOR")); System.out.println("GeraMapaXML - LerXML - JAN: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JAN")); System.out.println("GeraMapaXML - LerXML - FEV: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("FEV")); System.out.println("GeraMapaXML - LerXML - MAR: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("MAR")); System.out.println("GeraMapaXML - LerXML - ABR: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("ABR")); System.out.println("GeraMapaXML - LerXML - MAI: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("MAI")); System.out.println("GeraMapaXML - LerXML - JUN: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JUN")); System.out.println("GeraMapaXML - LerXML - JUL: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JUL")); System.out.println("GeraMapaXML - LerXML - AGO: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("AGO")); System.out.println("GeraMapaXML - LerXML - SET: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("SET")); System.out.println("GeraMapaXML - LerXML - OUT: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("OUT")); System.out.println("GeraMapaXML - LerXML - NOV: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("NOV")); System.out.println("GeraMapaXML - LerXML - DEZ: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("DEZ")); } } catch (IOException ex) { GeraLog.error("GeraMapaXML - LerXML - Erro: " + ex.getMessage()); } } Ele só consegue ler os dados do primeiro Indicador, quando vai ler o segundo dá erro. Alguém pode me ajudar a resolver esse problema?

Boa tarde amigo, para ficar mais fácil da comunidade ajudar vc seria interessante que postasse seu código usando as tags [code] e [\code]. E também postar a saída de erro que esta recebendo.

Abçs.

Conforme solicitado segue o xml e o código. O erro é que ele só le os dados do 1o indicador.

<?xml version="1.0" encoding="UTF-8"?>
<MAPAS>
<MAPA>
<MES_REF>11</MES_REF>
<ANO_REF>2012</ANO_REF>
<FLG_AMBIENTE>D</FLG_AMBIENTE>
<TIPO>ORCADO</TIPO>
<COD_MAPA>GENER-M-00084</COD_MAPA>
<DSC_MAPA>INSTI</DSC_MAPA>
<INDICADOR>
<COD_INDICADOR>GENER-I-00001</COD_INDICADOR>
<DSC_INDICADOR>Indicador de Teste</DSC_INDICADOR>
<VALORES>
<JAN>1</JAN>
<FEV>3</FEV>
<MAR>5</MAR>
<ABR>7</ABR>
<MAI>9</MAI>
<JUN>11</JUN>
<JUL>13</JUL>
<AGO>15</AGO>
<SET>17</SET>
<OUT>19</OUT>
<NOV>21</NOV>
<DEZ>23</DEZ>
</VALORES>
</INDICADOR>
<INDICADOR>
<COD_INDICADOR>GENER-I-00002</COD_INDICADOR>
<DSC_INDICADOR>Teste Indicador II</DSC_INDICADOR>
<VALORES>
<JAN>2</JAN>
<FEV>4</FEV>
<MAR>6</MAR>
<ABR>8</ABR>
<MAI>10</MAI>
<JUN>12</JUN>
<JUL>14</JUL>
<AGO>16</AGO>
<SET>18</SET>
<OUT>20</OUT>
<NOV>22</NOV>
<DEZ>24</DEZ>
</VALORES>
</INDICADOR>
</MAPA>
</MAPAS>

O programa:

public void LerXML(String mes, String ano, String codigo, String ambiente, String tipo) throws JDOMException {
String nome_mapa = "c:/logs/mapa_" + codigo + "_" + ano + mes + "_" + tipo + ".xml";
File arquivo = new File(nome_mapa);
SAXBuilder builder = new SAXBuilder();
try {
Document doc = builder.build(arquivo);
Element mapas = (Element)doc.getRootElement();
List mapa = mapas.getChildren();
Iterator m = mapa.iterator();
while (m.hasNext()) {
Element map = (Element) m.next();
System.out.println("GeraMapaXML - LerXML - MES_REF: " + map.getChildText("MES_REF"));
System.out.println("GeraMapaXML - LerXML - ANO_REF: " + map.getChildText("ANO_REF"));
System.out.println("GeraMapaXML - LerXML - FLG_AMBIENTE: " + map.getChildText("MES_REF"));
System.out.println("GeraMapaXML - LerXML - COD_MAPA: " + map.getChildText("COD_MAPA"));
System.out.println("GeraMapaXML - LerXML - DSC_MAPA: " + map.getChildText("DSC_MAPA"));
System.out.println("GeraMapaXML - LerXML - COD_INDICADOR: " + map.getChild("INDICADOR").getChildText("COD_INDICADOR"));
System.out.println("GeraMapaXML - LerXML - DSC_INDICADOR: " + map.getChild("INDICADOR").getChildText("DSC_INDICADOR"));
System.out.println("GeraMapaXML - LerXML - JAN: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JAN"));
System.out.println("GeraMapaXML - LerXML - FEV: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("FEV"));
System.out.println("GeraMapaXML - LerXML - MAR: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("MAR"));
System.out.println("GeraMapaXML - LerXML - ABR: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("ABR"));
System.out.println("GeraMapaXML - LerXML - MAI: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("MAI"));
System.out.println("GeraMapaXML - LerXML - JUN: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JUN"));
System.out.println("GeraMapaXML - LerXML - JUL: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("JUL"));
System.out.println("GeraMapaXML - LerXML - AGO: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("AGO"));
System.out.println("GeraMapaXML - LerXML - SET: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("SET"));
System.out.println("GeraMapaXML - LerXML - OUT: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("OUT"));
System.out.println("GeraMapaXML - LerXML - NOV: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("NOV"));
System.out.println("GeraMapaXML - LerXML - DEZ: " + map.getChild("INDICADOR").getChild("VALORES").getChildText("DEZ"));
}
} catch (IOException ex) {
GeraLog.error("GeraMapaXML - LerXML - Erro: " + ex.getMessage());
}
}

Amigo, também estou um programinha para ler aquivos xml, o que eu fiz, segui esta dica de outro tópico:

Não sei se estou falando besteira, mas acho que seu problema está ocorrendo por causa do nome igual das tags.
Creio que seu problema possa ser resolvido com a ajuda do topico acima.
Vou dar uma pesquisada aqui, mas se vc tbem tiver um tempo ai, procure sobre namespace em xml.

http://www.clem.ufba.br/tuts/xml/c14.htm

Assim que tiver alguma novidade vou postar aqui.
Até!