Hi,
I am having a really strange problem, I am fetching a database BLOB object containing the XMLs and then parsing the XMLs. The XMLs are having some UTF-8 Encoded characters and when I am reading the XML from the BLOB, these characters lose their encoding, I had tried doing several things, but there is no means I am able to retain their UTF encoding. The characters causing real problem are mainly double qoutes, inverted commas, and apostrophe. I am attaching the piece of code below and you can see certain things I had ended up doing. What else can I try, I am using JAXP parser but I dont think that changing the parser may help because, here I am storing the XML file as I get from the database and on the very first stage it gets corrupted and I have to retain the UTF encoding. I tried to get the encoding info from the xml and it tells me cp1252 encoding, where did this come into picture and I couldn't try it retaining back to UTF -8
Here in the temp.xml itself gets corrupted. I had spend some 3 days on this issue. Help needed!!!
ResultSet rs = null;
Statement stmt = null;
Connection connection = null;
InputStream inputStream = null;
long cifElementId = -1;
//Blob xmlData = null;
BLOB xmlData=null;
String xmlText = null;
RubricBean rubricBean = null;
ArrayList arrayBean = new ArrayList();
rs = stmt.executeQuery(strQuery);
// Iterate till result set has data
while (rs.next()) {
rubricBean = new RubricBean();
cifElementId = rs.getLong("CIF_ELEMENT_ID");
// get xml data which is in Blob format
xmlData = (oracle.sql.BLOB)rs.getBlob("XML");
// Read Input stream from blob data
inputStream =(InputStream)xmlData.getBinaryStream();
// Reading the inputstream of data into an array of bytes.
byte[] bytes = new byte[(int)xmlData.length()];
inputStream.read(bytes);
// Get the String object from byte array
xmlText = new String(bytes);
// xmlText=new String(szTemp.getBytes("UTF-8"));
//xmlText = convertToUTF(xmlText);
File file = new File("C:\\temp.xml");
file.createNewFile();
// Write to temp file
java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.FileWriter(file));
out.write(xmlText);
out.close();