开发者

How to convert Java to XML using Aegis?

How to convert a class into XML with Aegis?

Can´t find tutorials on the web, only r开发者_开发知识库andom code.


This will save it to a file :

 public void saveToXML(YourDomainObject obj) throws JAXBException, IOException {
                JAXBContext context = JAXBContext.newInstance(obj.getClass());
                Marshaller marshaller = context.createMarshaller();
                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                marshaller.marshal(obj, new FileWriter(new File("filename.xml")));

        }

Take a look at http://download.oracle.com/javase/6/docs/api/javax/xml/bind/Marshaller.html for more info what you can use beside serializing it to a file.


There are samples in the CXF distribution of using Aegis independently of web services.

Specifically, the `aegis_standalone' sample is what you want to look at.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜