1

Web サイトから見出しとリンクを返し、フォーム/文字列に表示する httpconnection アプリを作成しました。すべての見出しが 1 つの stringitem に表示される 1 つの文字列に連結されている場合、リンクから見出しを分離するにはどうすればよいですか?

コードは次のとおりです。

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