Jaxb - umarshaling mixed xml element with value

前端 未结 1 610
半阙折子戏
半阙折子戏 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 compOrValue;
    
        @XmlAnyElement
        @XmlMixed
        public List getCompOrValue() {
            return compOrValue;
        }
    
        public void setCompOrValue(List compOrValue) {
            this.compOrValue = compOrValue;
        }
    
    }
    
        

    0 讨论(0)
    提交回复
    热议问题