Im trying to get HTML image tag url from the given string. There should be some regular expression to get it. But don\'t know how to do it. Can anyone help me on this.
An XMLPullParser can do this pretty easily. Although, if it is a trivially small string, it may be overkill.
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser xpp = factory.newPullParser();
xpp.setInput( new StringReader ( "I have string like this with
some HTMLtag with
image tags in it. how can get it ?" ) );
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_TAG && "img".equals(xpp.getName()) {
//found an image start tag, extract the attribute 'src' from here...
}
eventType = xpp.next();
}