Hi!
I would like to read XML file from my SWING application, however list.size()
returns 0. Why does it happen? Thanks!
private void open() {
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File(openedFileName());
try{
Document document = (Document) builder.build(xmlFile);
Element rootNode = document.getRootElement();
List list = rootNode.getChildren("Panel");
for (int i=0; i< list.size(); i++)
{
Element node = (Element) list.get(i);
System.out.println("Name : " + node.getChildText("name"));
System.out.println("X : " + node.getChildText("x"));
System.out.println("Y : " + node.getChildText("y"));
System.out.println("Width : " + node.getChildText("width"));
System.out.println("Height : " + node.getChildText("height"));
}
}catch(IOException io){
System.out.println(io.getMessage());
}catch(JDOMException jdomex){
System.out.println(jdomex.getMessage());
}
}