【发布时间】:2011-11-03 07:31:30
【问题描述】:
我有一个 XML 文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object>
<str>the type</str>
<bool type="boolean">true</bool>
</object>
我想将它解组为下面类的对象
@XmlRootElement(name="object")
public class Spec {
public String str;
public Object bool;
}
我该怎么做?除非我指定命名空间(见下文),否则它不起作用。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object>
<str>the type</str>
<bool xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xsi:type="xs:boolean">true</bool>
</object>
【问题讨论】:
标签: xml jaxb unmarshalling