0
HTML = EntityUtils.toString(response.getEntity());
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String ResponseBody = httpclient.execute(httppost, responseHandler);
table = ResponseBody.substring(ResponseBody.indexOf("<table border=\"1\" cellpadding=\"0\" width=\"100%\" cellspacing=\"0\">"));
table = table.substring(0, table.indexOf("</table>"));  

String htmlString = table;
String noHTMLString = htmlString.replaceAll("\\<.*?\\>", "");
noHTMLString = noHTMLString.replaceAll("\r", "<br/>");
noHTMLString = noHTMLString.replaceAll("\n", " ");
noHTMLString = noHTMLString.replaceAll("\'", "&#39;");
noHTMLString = noHTMLString.replaceAll("\"", "&quot;");

TextView WORK = (TextView) findViewById(R.id.HTML);
WORK.setText(htmlString); 

正規表現を使用してHTMLコードを抽出しています。これは私のコードです。正しいように見えますが、抽出されたテキストではなく、テーブル (部分文字列) が返されます。誰も理由を知っていますか???

4

1 に答える 1

2

新しい String オブジェクトを TextView のソースとして使用する必要があります。これを変える:

WORK.setText(htmlString);

以下に:

WORK.setText(noHTMLString);
于 2013-03-19T14:57:48.820 に答える