I have a LWUIT j2me application that parses a local XML. I tried my code on the (Java TM Platform Micro SDK 3.0 DefultFxPhone 1) and on the asha simulator (Nokia_SDK_1_1_Java). Also I tested the code on different devices and it works fine. But, when I tested it on the (Nokia_SDK_2_0_Java simulator Nokia Asha 305) the condition in the while loop is always false.I think that there is something wrong with the parser. Any help? How can I figure out why do this problem happen only in the parser with this SDK. and i get this exception on the parseEvent event=Parser.read();
java.io.IOException
at com.sun.cldc.io.ResourceInputStream.read(+104)
at java.io.Reader.read(Reader.java:99)
at java.io.InputStreamReader.read(+11)
at org.kxml.parser.XmlParser.peekChar(+36)
at org.kxml.parser.XmlParser.peek(+68)
at org.kxml.parser.XmlParser.read(+11)
Here is the parsing code :
Reader reader = new InputStreamReader(in, "UTF-8");
XmlParser parser=new XmlParser(reader);
Vector items = new Vector();
String tipId;
String Text;
String tipImage;
String cateId = null;
String cateName;
String objId = null;
String objName;
ParseEvent event = parser.read();
ParseEvent readTextEvent = null;
while (event.getType() != Xml.END_DOCUMENT) {
switch (event.getType()) {
case Xml.START_TAG:
if (event.getName().equalsIgnoreCase("Category")){
cateId=event.getAttribute("id").getValue();
}
if (event.getName().equalsIgnoreCase("object")){
objId=event.getAttribute("id").getValue();
}
if (event.getName().equalsIgnoreCase("Tip")){
if(CategoryId.equals(cateId) && objectId.equals(objId))
{
readTextEvent=parser.read();
bean=new bean();
isItem=true;
}
}
if (isItem &&event.getName().equalsIgnoreCase("text")){
readTextEvent=parser.read();
Text = readTextEvent.getText();
bean.setTipText(Text);
}
if (isItem &&event.getName().equalsIgnoreCase("Image")){
readTextEvent=parser.read();
tipImage = readTextEvent.getText();
bean.setTipImage(tipImage);
isItem=false;
items.addElement(bean);
}
break;
case Xml.END_TAG:
if (event.getName().equalsIgnoreCase("Tip")) {
bean = null;
isItem = false;
}
break;
case Xml.TEXT:
break;
}
event = null;
event = parser.read();
}