Menu

How to save an SDT in an XML file?

Use Jaxb to marshal SDT in an XML file.

// step1: create the jaxb context
JAXBContext jaxbContext = JAXBContext.newInstance("sdt.xml");

// step2: create the marshaller
Marshaller marshaller = jaxbContext.createMarshaller();

// set xml file output format: line breaks and indentation will appear
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));

// step3: marshals the content tree whose root is in the sdt object
//and writes it as an output stream to the XML file
marshaller.marshal(sdt, new FileOutputStream("c://helloworldSDT.xml"));

Posted by Yan Tang Demey 2013-03-11

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.