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
Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10
Accepted Solution

Problem in XML parsing

Hi

Can any1 please tell me how to do Xml parsing in Blackberry. I am little bit confused in it.

 

Suppose this is my link:

{keyword:"keword", url:"videoUrl"}

 

while doing xml parsing:

String keyword1="";

 

element.getName.equalsIgnoreCase("keyword");

keyword1=element.getText();

 

is it write??

 

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

Re: Problem in XML parsing

your string looks like json to me, not xml.
----------------------------------------------------------
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
Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

Sorry by mistake but i have to know about xml parsing

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

Hey

Actualy the problem is i am getting response as

id:1

keyword:""

name:""

 

So the problem is with id. How do i access is??

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: Problem in XML parsing

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

Hey i am getting the response from the url and after getting the element i have to send it to next page. So the problem is i am not able to parse the id element.

 

Here is my code..

 

//parsing

for(int i=0;i<child_count;i++)
                {
                    Element element = rootElement.getElement(i);
                    if(element!=null)

//here is the keyword element

if(element.getName().equalsIgnoreCase("keyword"))
                        {
                            extraKeyword = element.getText();
                        }

 

 

//passing it to next screen

URLEncodedPostData urlEncodedPostData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, true);
urlEncodedPostData.append("keyword", extraKeyword);

 

but i am facing problem in id. Can you help??

its really urgent..

 

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in XML parsing

Hey its done.