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&#13;</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 (&#13) need remove first


Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -