Android XML clone node error with DOM

karansokhey

New Member
I've got a main XML (main.xml) with the next structure:\[code\]<partido> <datos_partido> .... </datos_partido> <estado_partido> ..... </estado_partido> <datos_partido> </datos_partido> .....<listado_acciones> .......</listado_acciones></partido>\[/code\]Where I want add the next XML (secondary.xml) inside the child :\[code\]<tiempo> <puntos> .... </puntos> <faltas> .... </faltas> ......</tiempo>\[/code\]The xml files are saved in the next routes:- main.xml is saved in /sdcard/DCIM/appName- secondary.xml is saved in /assets/I found both files and initialize both objects xmlDestiny and xml.To add secondary.xml inside main.xml in child "datos_parciales" I have developed next code:\[code\] private void addNewPeriod(String routeFile, String tagPosition){ XMLManager xmlDestiny = new XMLManager(Constants.ROUTE_APP + "main.xml"); XMLManager xml = new XMLManager(getApplicationContext(), "secondary.xml"); NodeList nodeList = xml.getRoot().getChildNodes();\[/code\]xmlDestiny.getRoot().getElementsByTagName("datos_parciales").item(0).appendChild(xmlDestiny.getRoot().adoptNode(nodeList.item(0).cloneNode(true)));\[code\] Node aux = xmlDestiny.getRoot().getElementsByTagName("tiempo").item(0); xmlDestiny.getRoot().renameNode(aux, null, tagPosition);} \[/code\]When I execute the preceding code, I've got an error (org.w3c.dom.DOMException) in the code in bold:\[code\]xmlDestiny.getRoot().adoptNode(nodeList.item(0).cloneNode(true));\[/code\]But, If I extract this code, and I develop a java app, not an android app, and I use the same code ... It works!!! But the same code in an android app doesn't work!!!What happend? What am I doing wrong? Please!!! Help me!!!Thanks in advance!!!
 
Top