Bonjour,
je souhaite récupérer sous forme de chaine de caractères indentée un objet de type org.w3c.dom.Document.
En cherchant sur le net, j'ai trouvé ce code là :
Le problème c'est que les classes utilisées font partie du package com.sun.etc... et lors de la compilation, j'ai les erreurs suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 ByteArrayOutputStream bos = new ByteArrayOutputStream(); Properties OP = OutputPropertiesFactory.getDefaultMethodProperties("xml"); OP.setProperty(OutputKeys.METHOD,"xml"); OP.setProperty(OutputKeys.INDENT,"yes"); OP.setProperty(OutputKeys.ENCODING,"UTF-8"); Serializer serializer = SerializerFactory.getSerializer (OP); serializer.setOutputStream(bos); serializer.asDOMSerializer().serialize(dom); //--- mon xml en chaine de caractères : String s = new String( bos.toByteArray());
J'ai trouvé sur le forum cet doc :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory is Sun proprietary API and may be removed in a future release com.sun.org.apache.xml.internal.serializer.Serializer is Sun proprietary API and may be removed in a future release com.sun.org.apache.xml.internal.serializer.SerializerFactory is Sun proprietary API and may be removed in a future release com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory is Sun proprietary API and may be removed in a future release com.sun.org.apache.xml.internal.serializer.Serializer is Sun proprietary API and may be removed in a future release com.sun.org.apache.xml.internal.serializer.SerializerFactory is Sun proprietary API and may be removed in a future release
Donc ma question est la suivante :Envoyé par adiGuba
Comment récupérer une chaine de craractères à partir d'un objet de type org.w3c.dom.Document sans utiliser ces classes là.
Merci d'avance
Partager