如何从cdata xmlnode获取图像源?
xmlnode:
<description><a href="http://www.site.com/id/?id=41564"><img src="http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg" align="left" /></a> more text comes here </description>
我正试图从描述节点中取出http://www.site.com//news/images/2010/03_march/imagestock/thumb/22.jpg ..
答案 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;
}