Hi Experts
I have problem in decryption an encrypted Xml file. because my Xml file contains utf-8 characters, this problem occurs. after many proccess on Xml data the following code throws an Exception:
try {
// Works if the content is a single child element.
byte [] a = decbit.getBytes("UTF-8");
ByteArrayInputStream bais2 = new ByteArrayInputStream(a);
Document decdoc = docBuilder.parse(bais2);
Node decNode =
encDoc.importNode(decdoc.g
etFirstChi
ld(), true);
edata.getParentNode().repl
aceChild(d
ecNode,eda
ta);
}catch(org.xml.sax.SAXPars
eException
spe) {
//In case the content is plain text
//or a group of child elements
Text decText = encDoc.createTextNode(decb
it);
edata.getParentNode().repl
aceChild(d
ecText,eda
ta);
}
decString = (getString((XmlDocument)en
cDoc));
--------
at the line with code "Document decdoc = docBuilder.parse(bais2); " an Exception occurs with message :
org.xml.sax.SAXParseExcept
ion: Illegal character at end of document, <.
whereas when I debug the project the filed "decbit", contains correct data. any way, in order to the exception, the control move to "catch" block and create a Text Node but the problem is the replaced data is like this:
<id root="588588588" extension="" displayable="false" /><beneficiaryOf typeCode="BEN">
<policyOrAccount classCode="COV" moodCode="EVN">
<id xsi:type="II" root="855855855" extension="" displayable="false" />
<author typeCode="AUT">
<carrierRole classCode="UNDWRT">
<id root="6548888888" extension="" displayable="false" />
</carrierRole>
</author>
</policyOrAccount>
</beneficiaryOf>
---
as you can see, tha "<" characters are < and the ">" characters are >
this really exhausted me, please help me out.
thank you, any help will be appreciated
regards
Mohammad
Start Free Trial