×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    118

    kxml2 removeChild problem

    hi everyone! i want to delete a specific node but the function destroys the structure of my xml

    this is my code:

    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 xml before i remove the child:

    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>
    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 statu</root>umber><msg>gj </msg></sms>
    it destroys my xml.what seems to be the problem? thanks

  2. #2
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    118

    Re: kxml2 removeChild problem

    can anyone please help me? please
    Last edited by binsint; 2011-02-10 at 16:52.

Similar Threads

  1. kXML2 Tutorial?
    By Army in forum Mobile Java General
    Replies: 12
    Last Post: 2010-08-25, 10:58
  2. KXML2 Problem - It is not being loaded by the project
    By Welysson in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2009-07-04, 08:40
  3. KXML2 problem
    By Thomassius in forum Mobile Java General
    Replies: 4
    Last Post: 2009-04-01, 22:33
  4. problem kxml, kxml2 class not found
    By kmsoomro in forum Mobile Java General
    Replies: 0
    Last Post: 2005-02-22, 08:55
  5. about kxml2.0
    By David.chow in forum Mobile Java General
    Replies: 4
    Last Post: 2003-12-17, 00:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×