code: public void toXml(final OptionElement root, final OutputStream str) throws OptionsException {
      Writer wtr = null;
  
      try {
        XmlEmit xml = new XmlEmit(true);
  
        wtr = new OutputStreamWriter(str);
        xml.startEmit(wtr);
  
        xml.openTag(outerTag);
  
        for (OptionElement oe: root.getChildren()) {
          childToXml(oe, xml);
        }
  
        xml.closeTag(outerTag);
      } catch (OptionsException ce) {
        throw ce;
      } catch (Throwable t) {
        throw new OptionsException(t);
      } finally {
        if (wtr != null) {
          try {
            wtr.close();
          } catch (Throwable t) {}
        }
      }
    }
docs: Emit the options as xml.
  
  @param root
  @param str
  @throws OptionsException