0

I'm developing Android app. There is a json, which contains field "thumb". "thumb" is a string with html code.

"thumb":"<img width=\"1280\" height=\"570\" src=\"http:\/\/xxx.xxx.com\/wp-content\/uploads\/2014\/11\/profesor--kosmos.jpg\" class=\"attachment-medium-size wp-post-image\" alt=\"Hello World" \/>"

The question is how to extract image url from this string to obtain smth like this:

String url = "http:\/\/xxx.xxx.com\/wp-content\/uploads\/2014\/11\/profesor--kosmos.jpg"

Task is not to download image or display it. Just to obtain URL.

ivkil
  • 414
  • 1
  • 4
  • 11
  • jsoup or any xml parser would do. (please no regex) – njzk2 Dec 12 '14 at 17:52
  • With String:indexOf() and String:substring() you can do that in only a few lines. No need for a heavy parser. – greenapps Dec 12 '14 at 17:58
  • There are already similar questions: [Extract image src from tag in android](http://stackoverflow.com/questions/25545370/extract-image-src-from-imgtag-in-android) [android java get html image tag from string](http://stackoverflow.com/questions/6998163/android-java-get-html-image-tag-from-string) – Filipe Batista Dec 12 '14 at 18:03
  • thanks. indexOf and substring are really the simplest solution for this. – ivkil Dec 20 '14 at 23:05

1 Answers1

0

if you are using phonegap, you can write this jquery to obtaing URL:

var stringURL=$('img').attr('src');

StartCoding
  • 394
  • 5
  • 16