Try this:

def slurper = new XmlSlurper()
def clean   = [:]
def parsed = slurper.parseText(inputString)

//Serialize to XML w/ preferred API

On Wed, Nov 15, 2017 at 5:33 AM, sally <> wrote:
I want to romeve namespaces from my xml response(now i am working inside nifi
environment,so i have to use groovy utilities) here is my code , but it
throws FlowfFileHandlingException, what should i change to make this code

import java.nio.charset.StandardCharsets
import groovy.lang.*
import java.util.concurrent.TimeUnit;
import java.lang.String;
import groovy.xml.XmlUtil

def flowFile=session.get();
 String removeXmlStringNamespaceAndPreamble(String xmlString) {
  return xmlString.replaceAll("(<\\?[^<]*\\?>)?", "").
  replaceAll("xmlns.*?(\"|\').*?(\"|\')", "")
  .replaceAll("(<)(\\w+:)(.*?>)", "${1}${3}")
  .replaceAll("(</)(\\w+:)(.*?>)", "${1}${3}");

 def text = '', {inputStream ->
   text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
   } as InputStreamCallback)

  def root = new XmlSlurper( false, false ).parse( text );
  String outxml = groovy.xml.XmlUtil.serialize( root );
    flowFile = session.write(flowFile, {outputStream ->
   }  as OutputStreamCallback)

Sent from: