【问题标题】:Simple Xml Framework not behaving as expected简单的 Xml 框架未按预期运行
【发布时间】:2014-05-08 20:46:23
【问题描述】:

我有这个 XML 字符串:

String str = "<order id='1234'><orderlines><orderline id='567'>"+
"<article id='890'><description>Bananen</description><todo>45</todo>"+
"</article></orderline></orderlines></order>";

我想使用 simple-framework 版本 2.7.1 阅读。在 orderline 类之前它工作正常,如下所示:

public class Orderline {
    @Attribute
    public int id;

    @Element
    public Article article;
}

我希望 descriptiontodo 元素“进入”Article,但我收到此错误:

05-08 22:45:23.958: D/debug(14854): 元素“描述”在第 1 行的类 nl.rd.svgtest.Orderline 中没有匹配项

我是这样解析的:

Serializer s = new Persister();
Order o = s.read(Order.class, str);

false 添加到s.read() 调用无效。

【问题讨论】:

    标签: java android simple-framework


    【解决方案1】:

    我在这里找到了答案:Java : Simple XML not parsing the xml. Gives Exception

    我必须将(inline=true) 添加到我的ElementList,如tutorial 中所示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 2020-06-28
      • 2012-02-18
      相关资源
      最近更新 更多