how get

后端 未结 2 1887
Happy的楠姐
Happy的楠姐 2020-12-22 08:24

how get the url a rss feed and open on in android




        
相关标签:
2条回答
  • 2020-12-22 08:59

    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 "";
    }
    
    0 讨论(0)
  • 2020-12-22 09:02

    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");
    
    0 讨论(0)
提交回复
热议问题