title: How do I quickly print a groovy.util.slurpersupport.Node?
body: <p>Is there an easy way to convert a <code>groovy.util.slurpersupport.Node</code> to a <code>groovy.util.Node</code>?</p>
  
  <p>I am trying to use the <code>XmlNodePrinter</code> on a node coming from an <code>XmlSlurper</code>, for some quick debugging. Here is my code (probably not the most elegant):</p>
  
  <pre><code>def xml = new XmlSlurper().parse( new File( path + pomFile ) )
  def services = xml.build.plugins.plugin.configuration.services
  services.children().findAll{ it.artifactId.text() == serviceName }.each { config -&gt;
  
      // begin section to dump "config" for debugging
      def stringWriter = new StringWriter()
      new XmlNodePrinter(new PrintWriter(stringWriter)).print(config[0])
      println stringWriter.toString()
      // end section to dump "config" for debugging
  
      // do some other processing on the config node
  }
  </code></pre>
  
  <p>This throws the following on the <code>config[0]</code> line:</p>
  
  <pre><code>org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'groovy.util.slurpersupport.Node@14712c3' with class 'groovy.util.slurpersupport.Node' to class 'groovy.util.Node'
  </code></pre>
  
  <p>How can I quickly print out the xml representation of <code>config</code>?</p>
  
  <p>I am limited to Groovy 1.7.0.</p>
  
  <p>-</p>
  
  <p><strong>EDIT</strong>: I also tried the following but receive an error:</p>
  
  <pre><code>services.children().findAll{ it.artifactId.text() == serviceName }.each { config -&gt;
       println XmlUtil.serialize(config)
  </code></pre>
  
  <p>Here's what's printed:</p>
  
  <pre><code>[Fatal Error] :1:1: Content is not allowed in prolog.
  ERROR:  'Content is not allowed in prolog.'
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>