public Element deserialize(Node c) throws NoSuchMethodException { if (c instanceof org.w3c.dom.Element) { org.w3c.dom.Element elm = (org.w3c.dom.Element) c; try { Element _elm = (Element) Class.forName(elm.getTagName().toLowerCase()) .getConstructors()[0] .newInstance(getContext(), this); for (int i = 0; i < elm.getAttributes().getLength(); i++) { Node attrib = elm.getAttributes().item(i); String val = attrib.getNodeValue(); String attribute = attrib.getNodeName(); try { int valN = Integer.valueOf(val); elm.getClass() .getMethod("set" + capitalize(attribute), Integer.class) .invoke(elm, valN); } catch (Exception e) { _elm.getClass().getMethod("set" + capitalize(attribute), String.class).invoke(elm, val); } for (int j = 0; j < elm.getChildNodes().getLength(); j++) { Element f = deserialize(elm.getChildNodes().item(i)); _elm.getChildren().add(f); } } return _elm; } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }