【问题标题】:How to parse the string response in android?如何解析android中的字符串响应?
【发布时间】:2013-07-22 12:26:25
【问题描述】:

我想知道在 Android 中写入和解析 XML 文件的最简单方法是什么。我的要求很简单。示例文件类似于:

<HTML>
<HEAD>
<TITLE>Network Error</TITLE>
</HEAD>
</HTML>

【问题讨论】:

  • httpPost.setEntity(new StringEntity(requestEnvelope)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); line = EntityUtils.toString(httpEntity);
  • Hi goody line is string
  • 如果您在字符串中有该行,那么您不能只查看字符串contains TITLE 标记,然后查看它后面的内容,在下一个 '>' 和 '
  • 你不能使用 stripHtml(line) 吗? public String stripHtml(String html) { return Html.fromHtml(html).toString(); }

标签: android html parsing xml-parsing response


【解决方案1】:

我知道了,我正在使用这种简单的格式,它工作正常谢谢。

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

【讨论】:

    【解决方案2】:

    在 android 中解析 XML 时,SAX 始终是最佳选择。您可以使用教程进行 SAX 解析

    参考:Click Here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      • 2023-03-27
      • 2021-07-24
      • 2014-09-03
      相关资源
      最近更新 更多