Jaxb - umarshaling mixed xml element with value

前端 未结 1 593
半阙折子戏
半阙折子戏 2020-12-21 07:32

I have the follwoing xml element:

text B inner text text B         


        
相关标签:
1条回答
  • 2020-12-21 08:18

    You can use a combination of @XmlAnyElement and @XmlMixed to achieve this:

    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;
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题