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
Trusted Contributor
maanbhati
Posts: 236
Registered: ‎07-28-2010
My Device: Not Specified
My Carrier: Software Developer

How to do SAX Parser in Blackberry

Hi All,

             I am new to the bb development , I want to do SAX Parsing in my bb application . Can any one help me how to do xml SAX Parsing in Blackberry.

 

Thanks to All

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to do SAX Parser in Blackberry

check the xmlparser sample
----------------------------------------------------------
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
Please use plain text.
Developer
BrajeshSanodiya
Posts: 130
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: How to do SAX Parser in Blackberry

Check this article.

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800599/How_To_...

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to do SAX Parser in Blackberry

That sample is DOM not SAX. 

Please use plain text.
Trusted Contributor
maanbhati
Posts: 236
Registered: ‎07-28-2010
My Device: Not Specified
My Carrier: Software Developer

Re: How to do SAX Parser in Blackberry

The given URL is for DOM parser I want to do SAX Parser into my bb application.

 

Thanks

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: How to do SAX Parser in Blackberry

the xmldemo seems also to be a dom sample, and as i did not find a sax sample here some small guidelines:

call http://www.blackberry.com/developers/docs/7.1.0api/javax/xml/parsers/SAXParser.html#parse(java.io.In... org.xml.sax.helpers.DefaultHandler) with the inputstream from your httpconnection (where you retrieve the xml).

http://www.blackberry.com/developers/docs/7.1.0api/org/xml/sax/helpers/DefaultHandler.html is where the parsing happens.
you begin with startDocument, then all elements are called one by one with startElement.
the value of an element is signaled using
http://www.blackberry.com/developers/docs/7.1.0api/org/xml/sax/helpers/DefaultHandler.html#character... int, int)

for a very simple document you would do the following:
Vector elements = new Vector() //at startDocument
Element element = new Element() //at startElement
element.setValue(new String(ch)) //at characters
elements.addElement(element) //at endElement
processElements //at endDocument

as the basic processing is not specific to j2me you can use any of the many saxparser samples available online for more in-depth guidelines.
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to do SAX Parser in Blackberry

Apologies, I should have added more to my previous post.  Thanks for adding the description Simon.

 

I think there are some great tutorials and information on SAX parsing that you will find if you search.  While you can't transplant the code, all the Java samples give you the basics and it is really pretty much the same.  So just look for Java samples.  You might find these useful too:

 

http://en.wikipedia.org/wiki/Simple_API_for_XML

 

http://oreilly.com/catalog/jenut2/chapter/ch19.html

Please use plain text.