2013-06-05 42 views
1

閱讀下面的博客後,我編組了一個對象。 missing XMLRootunmarshall without XmlRoot

T objectToSerialize; 
JAXBElement<T> je=new JAXBElement<T>(new QName(「namespace」,」RootName」), T.class,objectToSerialize); 
marshaller.marshall(je,writer); 

現在我想解組以來,我整理類沒有XmlRoot註解。我怎樣才能解除這個?

回答

0

您需要使用採用Class參數的解組方法之一。

JAXBElement<Foo> je = unmarshaller.unmarshal(source, Foo.class); 
Foo foo = je.getValue();