Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3124

Re: how to convert xml file to a string and write that string to another XML file format in XI/PI?

$
0
0

Hello,

 

Ok. You can use the below code to convert your xml data into string and replace the actual XML declaration with the blank string -

 

Header 1

public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException { 

         try { 

             InputStream inputstream = transformationInput.getInputPayload().getInputStream(); 

             OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream(); 

             // a) Copy Input content to String 

             byte[] b = new byte[inputstream.available()]; 

             inputstream.read(b); 

             String inputContent = new String(b); 

             

             inputContent = inputContent.replaceAll("<?xml version= \"1.0\" encoding= \"UTF-8\" ?>", ""); 

           

             outputstream.write(inputContent.getBytes()); 

         } catch (Exception exception) { 

             getTrace().addDebugMessage(exception.getMessage()); 

             throw new StreamTransformationException(exception.toString()); 

         } 

     } 

 

Regards,

Nitin


Viewing all articles
Browse latest Browse all 3124

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>