本文介绍了Android中的SimpleXML反序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有反序列化的Java对象的问题。对于反序列化我使用。
I have problem with deserialization java-object. For deserialization I use SimpleXML.
@Root
public class A {
@ElementList
private ArrayList<B> b;
getters, setters...
}
public class B{
@Element(name="C", required=false)
private C c;
getters, setters...
}
public class C{
private int id;
private String name;
getters, setters...
}
我接收XML,其中有一个字段:
I receiving XML, which have next field:
<A>
<B>
<C i:nil="true" />
</B>
</A>
Dalvink抛出一个异常:org.simpleframework.xml.core.AttributeException:属性'零'没有在行在B级比赛-1
Dalvink throws next exception: org.simpleframework.xml.core.AttributeException: Attribute 'nil' does not have a match in class B at line -1
是否有解决办法的任何想法?
谢谢你。
Are there any ideas for solution?Thanks.
推荐答案
通常空内容与psented $ P $
Usually null content is presented with
xsi:nil="true"
属性,如果这就是你想在这里做什么。
attribute if that's what you're trying to do here.
这篇关于Android中的SimpleXML反序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!