Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 109
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

xml parsing

The xml data is coming from server.And in Android it's taking 6 sec.But in Blackberry it's taking 15 sec.

 I want to know ,is there any fastest parsing techolgy available?They are reading the url line by line and we are i think so character by character.So can we do the same what they are doing? if yes,please tell how?

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: xml parsing

i never did any benchmarks, but from the "feel" kxml was the fastest of the few parsers i tested.
you can discern between pull parses (like sax or kxml) and dom parsers which download the full document first.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 108
Registered: ‎01-23-2012
My Device: torch,bold,curve,strom
My Carrier: Blackberry

Re: xml parsing

Hi ,

I am thinking that if you will use DOM parser then the speed will be improve!

 

So once check by using DOM parser!

Thanks & Regards,
Kumar Shivam
Developer
Posts: 109
Registered: ‎08-21-2012
My Device: Blackberry curve
My Carrier: company

Re: xml parsing

i need the technique to convert the data that is coming fron url to string...their i am finding that it is taking lot of time.

As it is coverting character by charecter.

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: xml parsing

standard approach would be:
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/IOUtilities.html#streamToBy...
from there you can create a string.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 108
Registered: ‎01-23-2012
My Device: torch,bold,curve,strom
My Carrier: Blackberry

Re: xml parsing

Hi,

 

 

use IoUtility.streamtobyte(input stream); method to convert input stream to btye array, and then use String str = new String(byte array);

 

hope this will work for you!

Thanks & Regards,
Kumar Shivam
Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: xml parsing

Once you have the data in a byte array, I suggest you leave it there and just package this as a ByteArrayInputStream to feed to your XML parser as a Stream.  Then it can decide if the XML has been encoded using UTF-8 or whatever as appropriate. 

 

At one time, I compared the speed of the supplied XML parser (using SAX) with one we had written, and our one processed twice as fast.  Similarly I suspect kXML will be faster than the built-in one too.  But in my experience, the parsing time is typically not significant when compared with the download time.