Looks good guruk. It's quite fast. I timed it. fyi: The code I posted earlier can also work with input of xml tags with attributes, such as
"Hello, this is a test <start attr1=\"value1\">12345</start> ..." which is common with tags, and it also avoids raising the nasty RuntimeException IndexOutOfBoundsException (by method substring) when a tag is not in the given string, which can happen in my apps. Exceptions such as these are normally not indicated by Eclipse Europa because, being RuntimeException children, they do not require a throws clause in the method signature when they are not caught by a try-catch in the method. These things often are what makes the difference between a 3-star and a 4-star rating. For handling absent tags without having to manage the exception downstream, I recommend the use of {if(xstart<0)return "";} String x1tag = "<" + xtag + ">"; String x2tag = "</" + xtag + ">"; int xstart = xhtml.indexOf(x1tag); if(xstart<0)return ""; int x1len = x1tag.length(); int xend = xhtml.indexOf(x2tag); if(xend<0)return ""; return xhtml.substring(xstart + x1len, xend); Or you could use a try-catch clause in the method if you know that the exception will not occur frequently and you don't want to do anything with the exception, and you want to keep going, such as: try{ String x1tag = "<" + xtag + ">"; String x2tag = "</" + xtag + ">"; int xstart = xhtml.indexOf(x1tag); int x1len = x1tag.length(); int xend = xhtml.indexOf(x2tag); return xhtml.substring(xstart + x1len, xend); }catch(Throwable resume){ return ""; } regards, serge On Mar 14, 2:38 pm, guruk <ilovesi...@gmail.com> wrote: > Hi and thanks for all your great help > > So I also like to share what I use now > > public String TakeIt (String xtag, String xhtml) > { > String x1tag = "<" + xtag + ">"; > String x2tag = "</" + xtag + ">"; > int xstart = xhtml.indexOf(x1tag); > int x1len = x1tag.length(); > int xend = xhtml.indexOf(x2tag); > return xhtml.substring(xstart + x1len, xend); > } > > And as Usual.. one Problem is solved, the next appear. > > Please if you know how to update a Gallery and also a Listview after a > Thread > answer > here:http://groups.google.com/group/android-beginners/t/1bdc014cee0d317b > > Great People!! > > Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---