I have the follwoing xml element:
<FIELD1><COMP VAR="A">text B</COMP> inner text <COMP VAR="B">text B</COMP></FIELD1>
如何使用JAXB注释此属性:
protected List<Object> compOrValue;
拥有一组 COMP XML 元素和字符串值的列表,使用 JAXB 是否可能?谢谢。
I have the follwoing xml element:
<FIELD1><COMP VAR="A">text B</COMP> inner text <COMP VAR="B">text B</COMP></FIELD1>
protected List<Object> compOrValue;
import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="FIELD1")
public class Root {
protected List<Object> compOrValue;
@XmlAnyElement
@XmlMixed
public List<Object> getCompOrValue() {
return compOrValue;
}
public void setCompOrValue(List<Object> compOrValue) {
this.compOrValue = compOrValue;
}
}