I don't know if this is the best way or not, you can build the DOM from
the input xml file and then serialize that DOM to XML by given UTF-8 encoding,
here is some sampe code.
InputSource is = new InputSource(inputs);
parser.parse(is);
Document document = parser.getDocument(); org.apache.xml.serialize.OutputFormat outputFormat = new
org.apache.xml.serialize.OutputFormat();
outputFormat.setPreserveSpace(false);
outputFormat.setIndenting(true); outputFormat.setIndent(4); outputFormat.setLineSeparator(System.getProperty("line.separator")); outputFormat.setLineWidth(0); outputFormat.setEncoding("utf-8");
OutputStream outArray = new ByteArrayOutputStream();
XMLSerializer serializer = new XMLSerializer(outArray, outputFormat); serializer.serialize(document); ..... Benson.
|
Title: Message
- Best way to read non-utf xml documents Praveen Peddi
- Re: Best way to read non-utf xml documents Suresh Babu Koya
- RE: Best way to read non-utf xml documents Benson Cheng