Noomak
Noomak

Reputation: 371

unable parsing XML with DOM4J

I'm having problems with XML parsing. I'm using dom4J but code seems to jump from read.read(xml) line to return c

public static ConfigFile buildClass(ConfigFile c, String xml) throws ParseException{

    try {
        SAXReader reader = new SAXReader();
        Document doc = reader.read(xml);


        Element root = doc.getRootElement();    
        String version = "";
        for ( Iterator i = root.elementIterator( "version" ); i.hasNext(); ) {
            Element foo = (Element) i.next();
            version = foo.getStringValue();
        }
        System.err.println(version);

    }
    catch(Exception ex){

    }


    return c;   

no console errors

Upvotes: 0

Views: 144

Answers (1)

rainkinz
rainkinz

Reputation: 10394

You're not seeing what's going on because you are completely ignoring any errors. At a minimum change the catch exception to:

catch(Exception ex){
  ex.printStackTrace();
}

So you can see why there is an error.

Upvotes: 2

Related Questions