cdm/src/main/java/ucar/nc2/ncml/NcMLWriter.java
public void writeToWriter(Element elem, Writer writer) throws IOException {
    xmlOutputter.setFormat(xmlFormat);
    elem.detach();  // In case this element had previously been added to a Document.
    xmlOutputter.output(new Document(elem), writer);
  }
public void writeToWriter(Element elem, Writer writer) throws IOException {
    xmlOutputter.setFormat(xmlFormat);
    elem.detach();  // In case this element had previously been added to a Document.
    xmlOutputter.output(new Document(elem), writer);
  }
Writes an NcML element to a Writer.

@param elem  an NcML element.
@param writer  the Writer to write the NcML document to. Will be closed at end of the method.
@throws IOException  if there's any problem writing.