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: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

How to parse XML with SOAP

Hello Friends, I need to parse this Soap Response and get the title from this. i tried a lot of samples but i cant parse the xml which has soap envelope. Please tell me how to parse this and get the title. Thanks

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTitleResponse xmlns="http://www.XYZ.com/ABC">
<Title>string</Title>
</GetTitleResponse>
</soap:Body>
</soap:Envelope>
Developer
Posts: 905
Registered: ‎02-07-2009
My Device: BlackBerry Torch 9800
My Carrier: Globe Telecom

Re: How to parse XML with SOAP

you can use KSoap2.

 

http://ksoap2.sourceforge.net/

 

 

Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: How to parse XML with SOAP

Thanks i used KSoap2 and i am able to get the title.

 

My next challenge is to read the response XML into a DOM Document. How to do that? any one please

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

Re: How to parse XML with SOAP

why do you want a DOM? You can deserialize directly to objects with ksoap2.
----------------------------------------------------------
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
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: How to parse XML with SOAP

[ Edited ]

ok i will make my doubht clearer

 

when i call

 

SoapObject result = (SoapObject)envelope.bodyIn;     
System.out.println(result.getProperty("JobData").toString());

 

 i get this string-

 

<Job ID="12343242"><MetaData Matter="This is some Matter"></MetaData></Job>

 

now i need to extract the job id ,matter into two strings. how to do that?

Message Edited by rihan007 on 29-07-2009 04:09 PM
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to parse XML with SOAP

create the objects and implement kserializable (i use a code generator for this).
add mappings for all objects you use and ksoap can create them.
----------------------------------------------------------
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
Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: How to parse XML with SOAP

hello simon..

 

Any samples or tutorials to do that ? i have been searching for that for long time. but in vain, 

 

any help would be greatly appreciated.!!!

New Developer
Posts: 58
Registered: ‎08-05-2009
My Device: Not Specified

Re: How to parse XML with SOAP

i want to use ksoap too. How can i add ksoap to my project? Shall i first download the jar file of ksoap and then add to my project? Where can i download it?

 

Thank you very much!

Developer
Posts: 455
Registered: ‎01-14-2009
My Device: Apple iPhone 3GS 16GB

Re: How to parse XML with SOAP

 Download from http://sourceforge.net/projects/ksoap2/

 

add the jar to as a library. If you get an error when you compile then you might need to preverify it. Try it and let me know

New Developer
Posts: 58
Registered: ‎08-05-2009
My Device: Not Specified

Re: How to parse XML with SOAP

Thanks a lot!

 

yes, after i built the project, jde showed me:Error!: Missing stack map at label. How should i do now?