1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
DOMSource source = new DOMSource(document);
URL location = new URL(url);
URLConnection urlc = location.openConnection();
urlc.setDoInput(true);
urlc.setDoOutput(true);
OutputStream stream = urlc.getOutputStream();
StreamResult result = new StreamResult(stream);
// Configuration du transformer
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.VERSION, "1.0");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
// Transformation
transformer.transform(source, result);
stream.flush();
stream.close(); |
Partager