0

how get the url <img src=''> a rss feed and open on in android

<description>
<img src="http://static.ibnlive.in.com/ibnlive/pix/sitepix/03_2010/google_new_630_90x62.jpg" alt="REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected to Hong Kong-based site." title="REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected to Hong Kong-based site." border="0" width="70" height="50" align="left" hspace="5"/>The company joins Google in protesting cyber attacks and censorship in China.
</description>
1
  • use JSoup library or XML Parser Commented Apr 10, 2014 at 8:49

2 Answers 2

2

If you want to get an URL from the XML above, you can try to use jsoup library:

String input = "<description>\n" +
            "<img src=\"http://static.ibnlive.in.com/ibnlive/pix/sitepix/03_2010/google_new_630_90x62.jpg\"" +
            " alt=\"REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected" +
            " to Hong Kong-based site.\" title=\"REDIRECTED: Google shut its Chinese portal" +
            " over censorship and visitors were being redirected to Hong Kong-based site.\"" +
            " border=\"0\" width=\"70\" height=\"50\" align=\"left\" hspace=\"5\"/>The company" +
            " joins Google in protesting cyber attacks and censorship in China.\n" +
            "</description>";
Document document = Jsoup.parse(input);
String output = document.select("img").first().attr("src");
Sign up to request clarification or add additional context in comments.

4 Comments

<description> <img src="static.ibnlive.in.com/ibnlive/pix/sitepix/03_2010/…" alt="REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected to Hong Kong-based site." title="REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected to Hong Kong-based site." border="0" width="70" height="50" align="left" hspace="5"/>The company joins Google in protesting cyber attacks and censorship in China. </description> i want to store in string ?can i use xml paring for img?
@Sanjay please explain in a better way
i want image between these tag <description><img src ="img url"></description> i already done this using JSoup but i wnat to do this using xml?how can i do this plz help me
@Sanjay so you want to load data from external source (.xml file, I suppose), that use XML Parser and get the necessary text?
1

first you should get description string with RssParser and then send that string to this method. YOU DON'T NEED TO LIBRARY. of course first you should replace " with ' for match your example with my answer and also choose an special word that just exist in your img url for "equals" in my code. like "pix" word that exist in your question.

private String helperString(String str) {
    String[] strings = str.split("'");
    for (String string: strings) {
        Log.i("STR", "string : " + string);
        String[] newString = string.split("/");
        for (String a: newString) {
            if (a.equals("images")){  //in your question pix or other words
                Log.i("URL", "Image Url is : " + string);
                return string;
            }
        }
    }
    return "";
}

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.