Android 从单行解析 Jsoup XML

Android Jsoup Parsing from Single line XML

正在解析来自 Xml 的简单单行文本,来自 url

 http://chat.brbchat.com:35555/online.xml?group=default

我的密码是

  private class ParseURL extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... strings) {
        StringBuffer buffer = new StringBuffer();
        try {
            Log.d("JSwa", "Connecting to [" + strings[0] + "]");
            Document doc = Jsoup.connect(strings[0]).get();
            Log.d("JSwa", "Connected to [" + strings[0] + "]");
            Elements topicList = doc.select("online");
            for (Element topic : topicList) {
                String data = topic.text();
                buffer.append(data);
            }

        } catch (Throwable t) {
            t.printStackTrace();
        }

        return buffer.toString();
    }
    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);
        respText.setText(s);
    }

但它不起作用.. 其他想法哪里错了

工作代码:

    try {
            Document doc = Jsoup.parse(Jsoup
                    .connect("http://chat.brbchat.com:35555/online.xml?group=default")
                    .get().toString(), "", Parser.xmlParser());

            Element online = doc.select("online").first();

            System.out.println(online.attr("ln"));
            System.out.println(online.attr("rn"));
            System.out.println(online.attr("cn"));

        } catch (IOException e) {
            e.printStackTrace();
        }

输出:

852
17
813