从cdata xmlnode获取图像源

时间:2010-03-15 12:09:01

标签: xml android split

如何从cdata xmlnode获取图像源?

xmlnode:

<description>&lt;a href=&quot;http://www.site.com/id/?id=41564&quot;&gt;&lt;img src=&quot;http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg&quot; align=&quot;left&quot; /&gt;&lt;/a&gt;  more text comes here </description>

我正试图从描述节点中取出http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg ..

1 个答案:

答案 0 :(得分:1)

好的,这对我有用..

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;
}