1

我编写了一个 httpconnection 应用程序,它返回标题和链接形成一个网站并显示在表单/stringtiem 上。鉴于所有标题现在都连接到一个字符串中,该字符串显示在一个字符串项上,我如何将标题与链接分开?

这是代码:

String line = results.toString();
            int position = line.indexOf("<h2 class=\"cross-head\">");
            position = line.indexOf(">", position);
            //
            int position2 = line.indexOf("</h3>", position);
            //
            res = line.substring(position + 1, position2);
            //
            while (res.indexOf("<") != -1) {

                int beginTag;
                int endTag;

                beginTag = res.indexOf("<");
                endTag = res.indexOf(">");
                if (beginTag == 0) {
                    res = res.substring(endTag + 1, res.length());
                } else {
                    res = res.substring(0, beginTag)
                            + res.substring(endTag + 1, res.length());
                }
                description = replace(res, "&quot;", "\"");
                description = replace(description, "&nbsp;", "");
                description = replace(description, "&rsquo;", "'");
                description = replace(description, "&lsquo;", "'");
                description = replace(description, "&ldquo;", "\"");
                description = replace(description, "&rdquo;", "\"");
                description = replace(description, "&ndash;", "-");

                description = replace(description, "&amp;", "&");
                description = replace(description, "&#039;", "'");
                description = replace(description, "Â", "");

            }
            //

            // End Parsing

            // display the page contents on the phone screen
            StringItem resultField = new StringItem(null, description,
                    Item.HYPERLINK);
            form.append(resultField);
4

0 回答 0