【问题标题】:SimpleXML Parser android getting HTML TAGSimpleXML Parser android 获取 HTML TAG
【发布时间】:2014-02-05 12:18:31
【问题描述】:

我有一个 TAG 获取整个描述在 SimpleXML 中变得越来越困难我应该提供什么属性来获取完整描述。 SimpleXML 也在解析 p 标签。

<description>
<p>

 Bar In Inconel</p> <ul> <li>600</li> <li>601</li> <li>617</li> <li>625</li> <li>718/718 NACE MRO</li> <li>725</li> <li>800</li> <li>825</li> <li>925</li> <li>K500</li> <li>MP35N</li> <li>X750</li> <li>C276</li></ul> <p>Aluminum Tubing, Aluminum Pipe, Aluminum Sheet, Aluminum Bar, Aluminum Plate In Aluminum</p> <ul> <li>2219</li> <li>2024</li> <li>2124</li> <li>3003</li> <li>5052</li> <li>6061</li> <li>7075</li> <li>7050</li></ul> <p>Stainless Steel In Tube, Pipe, Plate, Sheet &amp;

</p>
</description>

【问题讨论】:

  • 那么您是否只想将文本存储在没有html标签的字符串中?
  • no with the html tag org.simpleframework.xml.core.ElementException: Element 'p' does not have a match.This is the exception I want to description that should give the entire string with the html tag
  • @Element(name = "description", required = false, data = true) public String description;这不起作用

标签: android xml parsing simple-framework


【解决方案1】:

获得最终响应时,只需将 CDATA 标记括起来,并使该元素的 data=true

str = str.replaceAll("<description>","<description><![CDATA[");
str = str.replace("</description>", "]]></description>");

:D :D :D

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-12
  • 2012-04-08
  • 2011-08-16
相关资源
最近更新 更多