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: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to cut image path within the tag in blackberry

You code looks a little confused to me.  have you reviewed any of the online documentation on using a SAX parser?

 

Anyway, your start element should be called, And generally if I am looking for a tag, I look for it in there, comparing the localname.   Assuming I have fond the localname I want, then I go through the attributes, much as you have done.  Again I typically use the local name, and when I have fond the attribute I want, I process the value.

 

Now the bad news here is that the XML you actually want is packaged inside some XML.  So the processing I think you have to do is

a) Invoke a parser on the whole XML,

b) Once you have found your element (looking for "description" in startElement), set a flag, turn flag off if not your element

c) In characters() check the flag, and when you find the flag set, extract those characters.

d) Now you have the characters you have to parse, so you need to start another XML parser (actually I would not do this recursively, I would save the characters and let the first parser completeBut you can do it recursively if you wish.

e) In this XML parser you have to look for the img element, and then use code like we have already discussed to find the attribute you want.

 

If this is all the data you are getting I would be seriously tempted to just use indexOf to find the img=, then extract the URL from between the following quotation marksHaving to run two parsers to find this out seems like over killBut my suggestion is grubby.....

Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800

Re: how to cut image path within the tag in blackberry

Can i use attributes.getValue("img"); method to retrieve the values within the img tag??
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to cut image path within the tag in blackberry

No, it doesn't work like that. 

 

With the SAX parser you get notified as it parses the String, so it has to parse it. 

 

If you use the DOM parser, then you can use something like that to get the CDATA for <description>, then you will have to call the DOM parser again to extract the <img> tag and from there get the attribute.

Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800

Re: how to cut image path within the tag in blackberry

hey i got the url but the problem is that i am getting [0.0] at end of my url.how to neglect that??
Developer
Posts: 16,517
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: how to cut image path within the tag in blackberry

that is a bug of the debugger, it is only visible in eclipses debug window.
----------------------------------------------------------
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
Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800

Re: how to cut image path within the tag in blackberry

Now i am getting My proper URL but it have double quotations at the both the sides of the URL.how to remove that??
Developer
Posts: 16,517
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: how to cut image path within the tag in blackberry

how about String.substring.
There are good online courses on basic java.
----------------------------------------------------------
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
Contributor
Posts: 43
Registered: ‎07-21-2011
My Device: BB 9800

Re: how to cut image path within the tag in blackberry

i done with that ,i am getting URL without quotes.but i want to ask u one thing http://images.MYURL.com/img/news/11/oct/ett1[0.0] .jpg
the bug of debugger is coming in between my URl will it affect my URL??
Developer
Posts: 16,517
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: how to cut image path within the tag in blackberry

the output of the debugger is the output of the debugger, it does not affect your program in any way.
----------------------------------------------------------
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