Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
描述中的进程标记、Android、RSS、XML解析器_Android_Xml_Rss - Fatal编程技术网

描述中的进程标记、Android、RSS、XML解析器

描述中的进程标记、Android、RSS、XML解析器,android,xml,rss,Android,Xml,Rss,我的Android RSS阅读器有点问题。我正在使用XML解析器从RSS提要获取标记,但有时,在描述中,我有很多标记,比如,我有类似的问题,解决方案的一部分是,您可以将描述作为字符串,并将其传递给返回字符串数组以表示参数的方法。jsoup库可以帮助提取图像链接。仍然不知道它是否可以提取其他参数。 以下是我到目前为止所做的 public String[] stripHtml(String html) { Document document = Jsoup.parse(html);

我的Android RSS阅读器有点问题。我正在使用XML解析器从RSS提要获取标记,但有时,在描述中,我有很多标记,比如,
我有类似的问题,解决方案的一部分是,您可以将描述作为字符串,并将其传递给返回字符串数组以表示参数的方法。jsoup库可以帮助提取图像链接。仍然不知道它是否可以提取其他参数。
以下是我到目前为止所做的

public String[] stripHtml(String html) {
        Document document = Jsoup.parse(html);
        String picLink = document.select("img").first().attr("src");
        String result = Html.fromHtml(html).toString();
        result = result.substring(0, result.indexOf('['));
        String[] linkAndDescription = {picLink, result};

        return linkAndDescription;
    }
编辑 这是我的情况的完整解决方案,我想解析图像链接和描述文本

public String[] stripHtml(String html) {
        Document document = Jsoup.parse(html);
        //piclink
        String picLink = document.select("img").first().attr("src");
        //description
        String text = document.select("p").first().text();
        text = text.substring(0, text.indexOf('['));
        String[] linkAndDescription = {picLink, text};

        return linkAndDescription;
    }
public String[] stripHtml(String html) {
        Document document = Jsoup.parse(html);
        //piclink
        String picLink = document.select("img").first().attr("src");
        //description
        String text = document.select("p").first().text();
        text = text.substring(0, text.indexOf('['));
        String[] linkAndDescription = {picLink, text};

        return linkAndDescription;
    }