-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ashish,
Ashish Kulkarni wrote: > Here is the code where i read the dom tree and then convert it to a String, > then convert this string into Byte array and then user > DocumentBuilder().parse to parse it. Silly question... why are you going that? Is this just a test? > I get error in factory.newDocumentBuilder().parse(byteArray); > > TransformerFactory tFactory = > TransformerFactory.newInstance(); > Transformer transformer = tFactory.newTransformer(); > StringWriter writer = new StringWriter(); > DOMSource source = new DOMSource(doc); > transformer.transform(source, new StreamResult(writer)); > String obj = writer.toString(); Everything up to here is fine, except that there might be a problem with the XML emitter knowing what type of encoding you /will be/ using. Note that there are no encoding issues handled above, but you are converting the DOM tree into a String of characters. How does your XML library know what to put into "<?xml encoding="????" ?>"? > ByteArrayInputStream byteArray = new ByteArrayInputStream(obj.getBytes()); Here's one problem: you fail to specify the character encoding of the bytes returned by String.getBytes(). You should explicitly pass "UTF-8" (or something like that... ISO-8859-1 should work, too, as that includes Latin characters like the ones you mentioned). If you don't specify the character encoding (see the javadoc for String.getBytes()), I believe you get the default file encoding of the currently running JVM, which could be anything :( > Document doc = factory.newDocumentBuilder().parse(byteArray); This should work as long as you have properly converted characters into bytes above. The DOM parser ought to sniff the encoding from the "encoding" attribute of the XML processing instruction. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGJAFK9CaO5/Lv0PARAs1gAJ9a3udjyBpZtJ74VFFx4ldTcJ8nqgCfVShQ UiYGO31v+SdQCsKaeam1KvI= =nQFP -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]