1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
// Format de sorite du template
OutputFormat format = new OutputFormat(Method.XML, "UTF-8", true);
// Noeud à mettre dans un CDATA
String[] cdata = {"noeud1", "noeud2"};
format.setCDataElements(cdata);
format.setNonEscapingElements(cdata);
// Create the serializer
XMLSerializer serializer = new XMLSerializer(output, format);
// Handler du document
ContentHandler handler = serializer.asContentHandler() ;
Mapping mapping = new Mapping() ;
InputStream inputStream = new FileInputStream(new File("myfile")) ;
InputSource inpoutSource = new InputSource(inputStream) ;
mapping.loadMapping(inpoutSource) ;
Marshaller marshaller = new Marshaller(handler);
marshaller.setMapping(mapping);
marshaller.marshal(MyObject); |
Partager