How to unmarshall repeated nested classes with JAXB?

前端 未结 4 1899
故里飘歌
故里飘歌 2020-12-31 11:33

How can I instruct JAXB to process this ?

XML


 
    
          


        
4条回答
  •  死守一世寂寞
    2020-12-31 11:47

    Try this

    @XmlRootElement
    class Root {
        List allChildren = new ArrayList();
    
        private static class Parent  {
            @XmlElement
            Child child;
        }
    
        @XmlElement
        public void setParent(Parent p) {
            allChildren.add(p.child);
        }
    }
    

提交回复
热议问题