Hi all
Who can explain detaily how to install and make works kxml2.Im trying to use it but there are some errors with XmlPullParser.I've installed latest version of Eclipse.
Hi all
Who can explain detaily how to install and make works kxml2.Im trying to use it but there are some errors with XmlPullParser.I've installed latest version of Eclipse.
You need to add kXML's JAR file as a library, to your projects build path (right-click on the project, and look for "configure build path"). Under the "order and export" tab, make sure the kXML library has a "tick" next to it.
Graham.
Thanks man, i think that the problem of installing kxml now has gone,but there is new one.
"org.xmlpull.v1.XmlPullParserException: PI must not start with xml (position:unknown @1:5 in java.io.InputStreamReader@1cb37664) "
Any idea for this?!
I googled for "PI must not start with xml", and this is the first hit I found. Does it help?
Graham.
Yes, it was helpful for that man but again there is new one.
" java.lang.NullPointerException
at com.sun.cldc.i18n.Helper.getStreamReader(+15)
at com.sun.cldc.i18n.Helper.getStreamReader(+7)
at java.io.InputStreamReader.<init>(+9)
at com.parser.Tester.<init>(+46)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)"
When i click to the error it takes me to this line of codes "InputStreamReader is = new InputStreamReader(in);"
If you have any working project with kxml2 please post just for trying,maybe it will be useful to find out where is the problem.
you did initilaize the in variable you are using there right ? so it's value is not null ?
Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.
Yes i did.Take a look at this example:
HTML Code:package com.parser; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; import org.kxml2.io.KXmlParser; import org.kxml2.kdom.Document; import org.xmlpull.v1.XmlPullParserException; public class Tester extends MIDlet { KXmlParser parser = null; public String url = "/book.xml"; public Tester() { try { InputStream in = this.getClass().getResourceAsStream(url); InputStreamReader is = new InputStreamReader(in); parser = new KXmlParser(); try { parser.setInput(is); } catch (XmlPullParserException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } catch(IOException ioe) { System.err.println(ioe); ioe.printStackTrace(); parser = null; doc = null; return; } } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } protected void pauseApp() { } protected void startApp() throws MIDletStateChangeException { } }
Last edited by xmenus; 2010-07-16 at 19:50.
Solved.I've found the solution.Thanks to all especially to grahamhughes .
Regards.
heyy hii...
I am new to j2me.....this is my first application i am developing using j2me.....
and in this i need to extract data from xml file and display it on screen....and i am using KXML for this in NetBeans IDE...
but i am unable to access that file....
public String emp = "/dictxml2.xml";
parser = new XmlParser(new InputStreamReader(this.getClass().getResourceAsStream(emp)), 300);
here in the second line i get a NullPointerException....i kept this file in my source package,then also its throwing this Exception...
plz tell me whr did u keep the file which you accessed and how you solved it....plz...it would be a grt help for me!!
here is the full Exception detail...
TRACE: <at java.lang.NullPointerException>, startApp threw an Exception
java.lang.NullPointerException
at com.sun.cldc.i18n.Helper.getStreamReader(), bci=12
at com.sun.cldc.i18n.Helper.getStreamReader(), bci=4
at java.io.InputStreamReader.<init>(InputStreamReader.java:57)
at myPackage.MyFirstApplication.startApp(MyFirstApplication.java:87)
at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
heyy hii xmenus...
I am new to j2me.....this is my first application i am developing using j2me.....
and in this i need to extract data from xml file and display it on screen....and i am using KXML for this in NetBeans IDE...
but i am unable to access that file....
public String emp = "/dictxml2.xml";
parser = new XmlParser(new InputStreamReader(this.getClass().getResourceAsStream(emp)), 300);
here in the second line i get a NullPointerException....i kept this file in my source package,then also its throwing this Exception...
plz tell me whr did u keep the file which you accessed and how you solved it....plz...it would be a grt help for me!!
here is the full Exception detail...
TRACE: <at java.lang.NullPointerException>, startApp threw an Exception
java.lang.NullPointerException
at com.sun.cldc.i18n.Helper.getStreamReader(), bci=12
at com.sun.cldc.i18n.Helper.getStreamReader(), bci=4
at java.io.InputStreamReader.<init>(InputStreamReader.java:57)
at myPackage.MyFirstApplication.startApp(MyFirstApplication.java:87)
at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26