如何使用 XStream 存储 XML 标签的属性和值
我有以下 XML 文件,
<?xml version="1.0"?>
<paths>
<path action="M">some/path</path>
<path action="D">another/path</path>
</paths>
我尝试使用以下类读取它:
public class Paths {
@XStreamImplicit(itemFieldName="path")
private ArrayList<Path> paths;
}
@XStreamAlias("path")
public class Path {
String path;
@XStreamAsAttribute
private String action;
}
'action' (Path.action) 的值确实被存储。但我只得到 Path.path 变量的 NULL。
我可能做错了什么有什么想法吗?
I have the following XML file
<?xml version="1.0"?>
<paths>
<path action="M">some/path</path>
<path action="D">another/path</path>
</paths>
I am trying to read it using the following classes:
public class Paths {
@XStreamImplicit(itemFieldName="path")
private ArrayList<Path> paths;
}
@XStreamAlias("path")
public class Path {
String path;
@XStreamAsAttribute
private String action;
}
The value of 'action' (Path.action) is really stored. But I only get NULL for the Path.path variable.
Any ideas of what I might have done wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试ToAttributedValueConverter:
try ToAttributedValueConverter: