Android上的简单XML框架,类属性
我在 android 上的 simplexml 框架上遇到了一个奇怪的问题。我正在尝试从 xml 源读取并填充一个名为weatherdata 的对象。
XML 文件(对此没有控制):
<weatherdata>
<product class="pointData">
....
</product>
</weatherdata>
所以我的 java 文件看起来像:
@Root(name = "weatherdata", strict=false)
public class Weatherdata {
@Element(name="product", required = true)
protected ProductType product;
但我收到一个非常奇怪的错误:
01-14 14:22:28.919: W/System.err(18011): java.lang.ClassNotFoundException: pointData in loader dalvik.system.PathClassLoader
如果我尝试在 @Element 字段中 class=ProductType.class,它并不关心。即使我使用构造函数在项目中创建 pointData 类,错误也不会改变。它看起来像“class”作为保留关键字与简单的 xml 框架 2.6.2 的混乱。
我无法更改 xml。知道我该如何解决这个问题吗?谢谢。
Ive got a weird problem with simplexml framework on android. Im trying to read and fill an object called weatherdata from a xml source.
XML File (no control on this one):
<weatherdata>
<product class="pointData">
....
</product>
</weatherdata>
So my java file looks like :
@Root(name = "weatherdata", strict=false)
public class Weatherdata {
@Element(name="product", required = true)
protected ProductType product;
But I get a very weird error :
01-14 14:22:28.919: W/System.err(18011): java.lang.ClassNotFoundException: pointData in loader dalvik.system.PathClassLoader
If i try to class=ProductType.class in the @Element field, it doesn't care. Even when I create the pointData class in my projet with a constructor, the error doesnt change. It looks like "class" as a reserved keyword mess with simple xml framework 2.6.2.
I can't change the xml. Any idea how I could solve that ? thanks ahead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 TreeStrategy 将“类”替换为其他内容。
Try using TreeStrategy to substitute the "class" for something else.