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.

4
  • jsoup or any xml parser would do. (please no regex) Commented Dec 12, 2014 at 17:52
  • With String:indexOf() and String:substring() you can do that in only a few lines. No need for a heavy parser. Commented Dec 12, 2014 at 17:58
  • There are already similar questions: Extract image src from <img>tag in android android java get html image tag from string Commented Dec 12, 2014 at 18:03
  • thanks. indexOf and substring are really the simplest solution for this. Commented Dec 20, 2014 at 23:05

1 Answer 1

0

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.