hi everyone! i want to delete a specific node but the function destroys the structure of my xml
this is my code:
this is my xml before i remove the child:Code:public void deleteItem(String path,String filename,int index) throws IOException { currentMenu="Forward"; String url = path + filename; fc = (FileConnection) Connector.open(url,Connector.READ_WRITE); in = fc.openInputStream(); document = new Document(); isr = new InputStreamReader(in); try { parser.setInput(isr); document.parse(parser); Element el_root = document.getRootElement(); Element el_sms = el_root.getElement(index + 1); el_sms.removeChild(index+1); os = fc.openDataOutputStream(); serializer.setOutput(os, "UTF-8"); document.write(serializer); fc.close(); in.close(); isr.close(); } catch (Exception ioe) { } }
this is my xm AFTER i use removeChild();Code:<?xml version='1.0' encoding='UTF-8' standalone='no' ?> <root> <sms status="read"><number>639274666258</number><msg>j </msg></sms><sms status="read"><number>639274666258</number><msg>gj </msg></sms> </root>
it destroys my xml.what seems to be the problem? thanksCode:<?xml version='1.0' encoding='UTF-8' standalone='no' ?> <root> <sms status="read"><number>639274666258</number><msg>j </msg></sms><sms statu</root>umber><msg>gj </msg></sms>

Reply With Quote

