reading cdata with binary data in xml by java -
i have xml coming response of soap web service. xml following--
<![cdata[<?xml version="1.0" encoding="utf-8"?><pro_code>abce096</pro_code> <pdf_stream>jvberi0xljqkjeljz9mkmsawig9iajw8l0jhc2vgb250l1rpbwvzlvjvbwful1r5cguvrm9udc9f </pdf_stream>]]>
by using following have picked pro_code
xpath.compile("//illustrations/product_code/text()").evaluate(doc, xpathconstants.nodeset))....
but, pdf_stream bytestream. how can read , convert pdf?
the content of pdf encoded in base64
. can decode using base64.getdecoder().decode(string)
if use java 8.
you can find more details base64
decoder here.
if don't use java 8, can still use base64 apache commons codec
.
nb: have trailing html entity (
) need remove first
Comments
Post a Comment