on 10-27-2006 7:20 AM
Hi,
I have an XML file & i have converted it into hexadecimal to store in backend.Now i have to convert this hexadecimal value to XML file.How can i do that .Apart from that this xml should be in correct format.
thanx & regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm not sure if this the correct way to store files in DB. Why don't you just take the bytes with the correct encoding, save them in the DB. When you want to extract the String from the DB, you could read the bytes in byte array, write them in file or create a string with the proper encoding.
You could encode String as a BigInteger but this is highly ineffective.
Cheers,
Toshe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Toshe,
Actually this is an XML document what i m storing in DB.DB is sap r/3 & its data type is xstring which takes only hex values.I m able to convert it back to string & its printing complete xml as a string but the problem is that i want xml document bcos i have to render it on webdynpro UI.Can you tell me how can i convert this string to an XML document??
regards
Sumit
Hi Sunil,
I got your problem, you need to convert the <b>String</b> to a <b>Document</b> object. Use the following code to do it,
String str = "<xml></xml>";
InputStream is = new StringBufferInputStream(str);
DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dBF.newDocumentBuilder();
Document doc = builder.parse(is);
I'm sure that'll help you.
Best regards,
Guru.
Hi Sumit,
Can you elaborate on the method (post some code snippet as well) that you used in the conversion. That will help me in solving your problem.
Regards,
Guru.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guru,
This is the code :
String d = writtenDocument.toString();
byte[] bytes = d.getBytes("US-ASCII");
BigInteger bi = new BigInteger(bytes);
String s = bi.toString(16);
if (s.length() % 2 != 0) {
// Pad with 0
s = "0" + s;
}
Here writtenDocument is org.w3c.dom.Document.
Thanx & Regards
Sumit
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.