private void guardaRes(String resu, CliGol cliGol) throws ParserConfigurationException, SAXException, IOException { String[] nodos = {"NoHit", "Hit", "Buro"}; DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputSource is = new InputSource(new StringReader(resu)); Document xml = db.parse(is); Element raiz = xml.getDocumentElement(); String nombre = obtenerNombre(raiz); for (String s : nodos) { Node nodo = raiz.getElementsByTagName(s) == null ? null : raiz.getElementsByTagName(s).item(0); if (nodo != null) { String informacion = sustraerInformacionNodo(cliGol, nodo); guardarEnListas(nodo.getNodeName(), nombre + "," + informacion); } } }
private String sustraerInformacionNodo(CliGol cliGol, Node nodo) { String[] excluye = { "CLI_ID", "CLI_SAP", "CliApePat", "CliApeMat", "CliNom", "CLI_FEC_NAC", "CLI_DOM_CAL", "CLI_DOM_NUM_EXT", "CLI_DOM_NUM_INT", "CLI_DOM_COL", "CLI_POS_ID", "CliGolP1", "CliGolP8", "CliGolP10", "CliGolP11", "CliGolP15", "CliGolP17", "CliGolP18", "CliGolP25", "CliGolResAct", "CliGolNumTar", "CliGolCtaChe", "CliGolCrePer", "CliGolCreAut", "CliGolCreHip", "CliGolOtrCre", "CliBurMens", "PagRnt", "CliGolBurCre", "CliBurValr", "CliGolIng", "CliGolImpRen" }; NodeList variables = nodo.getChildNodes(); LinkedHashMap[] mapas = obtenerMapeos(cliGol, variables, excluye); Dao dao = new Dao(); Object[] descripciones = dao.ObtenLista(mapas[0], Arrays.asList(excluye)); // <variable,puntos>,descripciones return unirMapeos(mapas[1], descripciones); }