Reputation: 1237
I am encrypting data suing PKCS-7 using this value inside a xml tag , when i am parsing this xml it is giving me
[Fatal Error] :1:108: An invalid XML character (Unicode: 0x6) was found in the element content of the document. ERROR : org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x6) was found in the element content of the document.
Please help me to fix this issue
Thanks A Lot
Upvotes: 0
Views: 2213
Reputation: 25034
One way to enclose binary data in an XML document is to base-64 encode the value. Otherwise (as you have discovered) the data are apt to include characters that aren't legal in XML data streams. XML does allow some control characters, but only U+0009 (tab), U+000A (LF), and U+000D (CR).
Using base64 does require, of course, (a) that whatever system you are using to generate the XML has a function for performing base64 encoding (if you have an encryption library to produce the PKCS7, I'm guessing you have a base64 encoding function), and (b) that all the systems that consume the XML you are producing know to expect the value to be base64-encoded. If you are using an XSD schema to define the contract between data sources and data sinks, the schema can easily be made to say the value of the element in question must be base-64 encoded. Otherwise, you just have to document the fact.
Upvotes: 1
Reputation: 437
It seems like the PKCS7 text has an invalid character, the "ACK"
You can read in this other answer about it:
An invalid XML character (Unicode: 0xc) was found
Upvotes: 1
Reputation: 2387
The ACK character is not allowed in XML. You'd probably to encode your PKCS-7 String in the XML prior to parse it.
Upvotes: 1