Add basic (but not yet working) XML parsing helper
This commit is contained in:
parent
b7a21d4be2
commit
cfd481a22b
@ -7,7 +7,6 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
@ -0,0 +1,21 @@
|
||||
package at.technikumwien.movies;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class XmlHelper {
|
||||
public static void moviesToXml(List<Movies> movies,String filename) throws Exception {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(Movies.class);
|
||||
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
|
||||
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
|
||||
// FIXME: Can't marshal list
|
||||
marshaller.marshal(movies, System.out);
|
||||
marshaller.marshal(movies, new File(filename));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user