×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    5

    Unhappy Need a Help in Xml in J2me

    I am Developin an application to read data form an XML file

    So I am Having Some issues ,please Any one No about this this please help me

    Xml file.......
    <data_file log_date="2008-11-25">
    <ac_no>RAT/SUP/000673454</ac_no>
    <ac_type>Savings</ac_type>
    <ac_open_balance>359149.10</ac_open_balance>
    <ac_close_balance>1392824.08</ac_close_balance>

    <data>

    <row>
    <date>11-Nov-2008</date>
    <datail>Deposit</datail>
    <deposit>103750.00</deposit>
    <balance>13392543.23</balance>
    </row>

    <row>
    <date>31-Oct-2008</date>
    <datail>Withedrawal</datail>
    <withdrawal>3600.00</withdrawal>
    <balance>12569284.23</balance>
    </row>

    <row>
    <date>31-Oct-2008</date>
    <datail>Deposit</datail>
    <deposit>34600.00</deposit>
    <balance>12439287.10</balance>
    </row>

    <row>
    <date>31-Oct-2008</date>
    <datail>Deposit</datail>
    <deposit>51294.00</deposit>
    <balance>12786875.23</balance>
    </row>

    <row>
    <date>29-Oct-2008</date>
    <datail>Deposit</datail>
    <deposit>103750.00</deposit>
    <balance>10543624.23</balance>
    </row>

    <row>
    <date>29-Oct-2008</date>
    <datail>Deposit</datail>
    <deposit>103750.00</deposit>
    <balance>10394246.23</balance>
    </row>

    <row>
    <date>21-Oct-2008</date>
    <datail>Deposit</datail>
    <deposit>77654.23</deposit>
    <balance>873286.23</balance>
    </row>
    </data>
    </data_file>



    This kind of Xml Details I am trying to get Data ....I used KXML
    So please be Kind enough to give some advice


    thankzzz,
    in advance

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: Need a Help in Xml in J2me

    Hi,

    You have not mentioned what error you are getting when you try to fetch the data from the XML file. Please clearly state that what error you are getting while fetching data from the XML.
    Sunil
    Mobile Application Developer

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    5

    Red face Re: Need a Help in Xml in J2me

    Quote Originally Posted by sunil_bhambani123 View Post
    Hi,

    You have not mentioned what error you are getting when you try to fetch the data from the XML file. Please clearly state that what error you are getting while fetching data from the XML.

    Thank you putting ur time my problam Sunil ,I am trying to get this data from this Xml file this is the

    code I am Using
    -------------------------------------------------------------
    package src;

    import java.io.IOException;
    import java.io.InputStreamReader;
    import javax.microedition.io.Connector;
    import javax.microedition.io.HttpConnection;
    import org.kxml2.io.KXmlParser;
    import org.xmlpull.v1.XmlPullParser;
    import org.xmlpull.v1.XmlPullParserException;

    class ReadXML extends Thread {

    public void run() {
    try {
    HttpConnection httpConnection = (HttpConnection) Connector.open("URL FOR The XML FILE");
    KXmlParser parser = new KXmlParser();
    parser.setInput(new InputStreamReader(httpConnection.openInputStream()));
    parser.nextTag();
    parser.require(XmlPullParser.START_TAG, null, "data_file");
    while (parser.nextTag() != XmlPullParser.END_TAG) {
    readXMLData(parser);
    }
    parser.require(XmlPullParser.END_TAG, null, "data_file");
    parser.next();
    parser.require(XmlPullParser.END_DOCUMENT, null, null);
    } catch (Exception ex) {
    ex.printStackTrace();
    }

    }

    private void readXMLData(KXmlParser parser)
    throws IOException, XmlPullParserException {


    //Parse our XML file
    parser.require(XmlPullParser.START_TAG, null, "data");





    Book book = new Book();


    while (parser.nextTag() != XmlPullParser.END_TAG) {


    parser.require(XmlPullParser.START_TAG, null, null);

    String name = parser.getName();

    String text = parser.nextText();

    System.out.println("<" + name + ">" + text);


    if (name.equals("ac_no")) {
    book.setName(text);
    } else if (name.equals("ac_type")) {
    book.setDescription(text);
    } else if (name.equals("ac_open_balance")) {
    book.setAuthor(text);
    } else if (name.equals("ac_close_balance")) {
    book.setRating(text);
    /*else if (name.equals("available"))
    book.setAvailable(text);
    */
    }
    parser.require(XmlPullParser.END_TAG, null, name);
    }

    //bookVector.addElement(book);



    parser.require(XmlPullParser.END_TAG, null, "data");



    }
    }


    ---------------------------------------------------------------
    But I cant move to the Nodes Correctly

    So Please Be Kind enough to help me so I would be able complete

    this Application

    Thank you
    Keshawa

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    30

    Re: Need a Help in Xml in J2me

    wen the parser parses an xml file it will read; in ur case; 3 things..the start tag, the text in between and the end tag...now i dont exactly knoe wats the problem...but taking a guess i would say...after the first getText() wen ur while loop calls the nextTag() ur parser doesnt move to the next start tag...rather now it moves on to the end tag ....neways not so sure abt this....a debugger will help u a lot....chk out the local variables in a debug environment if u r usin ne IDE...ull know wats happenin....it will tell u wat are the current tags and text ur parser variable is reading .....

Similar Threads

  1. Can J2ME be used for sending MMS Message ?
    By seno_ap in forum Mobile Java General
    Replies: 1
    Last Post: 2006-11-24, 14:36
  2. help on linking XML databases to J2ME.
    By yenpaul2001 in forum Mobile Java General
    Replies: 0
    Last Post: 2006-01-22, 18:43
  3. need urgent guidance on j2me
    By cogni_niru in forum Mobile Java General
    Replies: 1
    Last Post: 2005-11-13, 15:02
  4. XML Schema parser for J2ME???
    By Pepper_91 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-10-11, 00:37

Posting Permissions

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