×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    9

    how can i modify file xml into midlet

    String fileName = "file:///root1/books.xml";
    DataOutputStream os = null;



    FileConnection fc = null;
    try {
    fc = (FileConnection) Connector.open(fileName);
    Document d = new Document();

    Element catalog = d.getElement("", "catalog");



    Element book = catalog.getElement("", "book");



    Element title = book.getElement("", "title");
    title.removeChild(0);
    title.addChild(Element.TEXT, "Spider World: The Tower");



    Element publish = book.getElement("", "publish-date");
    publish.removeChild(0);
    publish.addChild(Element.TEXT, "1987");







    os = fc.openDataOutputStream();
    KXmlSerializer serializer = new KXmlSerializer();
    serializer.setOutput(os, "UTF-8");
    d.write(serializer);







    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();



    }
    catch (Throwable t) {
    System.out.println("Exception:"+t);
    t.printStackTrace();
    }

    }



    My file xml





    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE catalog [
    <!ELEMENT catalog (book)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT book (publish-date|genre|title|author)*>
    <!ATTLIST book
    id CDATA #IMPLIED
    >



    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT author (#PCDATA)>



    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT title (#PCDATA)>



    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT genre (#PCDATA)>



    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT publish-date (#PCDATA)>
    ]>
    <catalog>
    <book id="1">
    <author>Colin Wilson</author>
    <title>The Mind Parasites</title>
    <genre>Horror novel, Science fiction novel</genre>
    <publish-date>1967</publish-date>
    </book>
    </catalog>





    My proble that when i run



    Exception:java.lang.RuntimeException: Element {}catalog not found in org.kxml2.kdom.Document@1cb37664
    java.lang.RuntimeException: Element {}catalog not found in org.kxml2.kdom.Document@1cb37664
    at org.kxml2.kdom.Node.getElement(+84)
    at Midlet.startApp(+33)
    at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:43)
    at com.sun.midp.midlet.Scheduler.schedule(Scheduler.java:374)
    at com.sun.midp.main.Main.runLocalClass(Main.java:466)
    at com.sun.midp.main.Main.main(Main.java:120)





    PLEASE HELP ME

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: how can i modify file xml into midlet

    Hi,
    Nobody has got so much of time that he will read the total code and then read the exceptions list and then reply to your post and your issue gets solved,

    Please explain the issue in words,not just copy and paste the error prone code,and try to expect and imagine the solution.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Super Contributor
    Join Date
    Feb 2006
    Posts
    689

    Re: how can i modify file xml into midlet

    Hi,
    Please post at which point in your code does the exception occurs.
    Thanks
    Soku

Similar Threads

  1. Parsing xml data from the server using kxml2 in J2ME
    By dninsiima in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2010-03-26, 08:08
  2. Regarding BMCONV
    By sanah007 in forum Symbian
    Replies: 2
    Last Post: 2009-05-26, 12:47
  3. Error : Cannot find file : for DUMMIES
    By PACALA_BA in forum Symbian
    Replies: 7
    Last Post: 2008-07-06, 13:18
  4. Error with makesis.exe and creating the .pkg file
    By gramya87 in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2007-10-10, 13:53
  5. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46

Posting Permissions

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