tags:

views:

125

answers:

2

Hi , I start testing android , trying to get image from xml my Image is hosting inside xmlnode <a href="http://www.site.com/id/?id=41564&quot;&gt;&lt;img src="http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg&quot; align="left" /></a> more text comes here

i trying to get the http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg and displaying it ...

Can you help me with that ?

Thanks zOro..

A: 

Sorry ..

I worth somting like that :

  My text is (_HtmlString):
  <a href='http://www.mywebsite.com'&gt;
   <img src='http://www.mywebsite.com/HelloPic.gif'
  border='0' width='116' height='116'></a></div> 
   more text comes here ... 

 static  String getImageFromFeed(String _HtmlString) {

  Pattern p=null;
  Matcher m= null;
  String sUrl ="";

      //I tryied with out success  this one as pattern:
            // src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')?")
      p= Pattern.compile("still looking for the right pattern");
      m= p.matcher(_HtmlString);

if  (m.find())
   {
  sUrl=m.toString();
   }


return sUrl;
}

that give me a lead..

Thanks..

Zohar Adar
A: 

ok , this is work for me ..

static  String getImageFromFeed(String _HtmlString) {

    Pattern p=null;
    Matcher m= null;
    String sUrl ="";



    try {

         p= Pattern.compile("src='(.*?)'");
         m= p.matcher(_HtmlString);

    } catch (Exception e) {
        sUrl = e.toString();
    }

    if  (m.find())
         {
          sUrl=m.group(1);

         }

    return sUrl;
}
Zohar Adar