Pessoal , estou tentando ler de uma arquivo XML mas ta me retornando null para os campos : segue o arquivo xml :
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : confXML.xml
Created on : 12 de Setembro de 2007, 16:30
Author :
Description:
Purpose of the document follows.
-->
<root>
<config-datasource>
<oracle BD="Oracle" >
<driver>jdbc:oracle:thin:@</driver>
<host>server</host>
<port>1521</port>
<banco>BANCO</banco>
<user>U53344</user>
<passw>U5334434000</passw>
<min-pool-size>10</min-pool-size>
<acquire-increment>5</acquire-increment>
<max-pool-size>50</max-pool-size>
<acquire-retry-attempts>3</acquire-retry-attempts>
</oracle>
</config-datasource>
<look-and-feel>
<default></default>
</look-and-feel>
</root>
e a minha classe para ler o XML :
/*
* LendoXML.java
*
* Created on 12 de Setembro de 2007, 14:33
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package util;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
/**
*
* @author
*/
public class LendoXML {
/** Creates a new instance of LendoXML */
public LendoXML() {
}
public void lerXML(){
try {
File f = new File("src/conf-datasource/confXML.xml");
SAXBuilder sb = new SAXBuilder();
Document d = sb.build(f);
Element mural = d.getRootElement();
List elements = mural.getChildren();
Iterator i = elements.iterator();
while (i.hasNext()) {
Element element = (Element) i.next();
System.out.println("" + element.getAttributeValue("oracle"));
System.out.println(""+ element.getChildText("driver"));
System.out.println(""+ element.getChildText("host"));
System.out.println(""+ element.getChildText("port"));
System.out.println(""+ element.getChildText("banco"));
System.out.println(""+ element.getChildText("user"));
System.out.println(""+ element.getChildText("passw"));
System.out.println(""+ element.getChildText("min-pool-size"));
System.out.println(""+ element.getChildText("acquire-increment"));
System.out.println(""+ element.getChildText("max-pool-size"));
System.out.println(""+ element.getChildText("acquire-retry-attempts"));
}
} catch (JDOMException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
vlw