我有一个如下所示的 xml:
<Root>
<tag1>4</tag1>
<tag2>aa</tag2>
<tag3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<anyType xsi:type="xsd:string">bla bla bla</anyType>
<anyType xsi:type="xsd:string">3</anyType>
</tag3>
</Root>
xjc生成的对象是:
public class Root {
@XmlElement(name="tag1")
protected short tag1;
@XmlElement(name="tag2")
protected String tag2;
@XmlElement(name="tag3")
protected Object tag3;
}
当我解码 xml 时,我在 tag3 中得到某种 xml 元素。 我需要一些通用的东西来将 tag3 中的值放入列表中。
有什么想法吗?
谢谢。
最佳答案
创建 AnyType 类。并将 tag3 贴花为 AnyType 数组
@XmlElement(name="tag3")
protected AnyType[] tag3;
关于java - 如何使用jaxb获取anyType值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7066635/