public void write(Writer writer) throws IOException { if (this.name == null) { this.writeEncoded(writer, this.contents); return; }  writer.write('<'); writer.write(this.name);  if (! this.attributes.isEmpty()) { Enumeration en = this.attributes.keys();  while (en.hasMoreElements()) { writer.write(' '); String key = (String) en.nextElement(); String value = (String) this.attributes.get(key); writer.write(key); writer.write('='); writer.write('"'); this.writeEncoded(writer, value); writer.write('"'); } }  if ((this.contents != null) && (this.contents.length() > 0)) { writer.write('>'); this.writeEncoded(writer, this.contents); writer.write('<'); writer.write('/'); writer.write(this.name); writer.write('>'); } else if (this.children.isEmpty()) { writer.write('/'); writer.write('>'); } else { writer.write('>'); Enumeration en = this.enumerateChildren();  while (en.hasMoreElements()) { XMLElement child = (XMLElement) en.nextElement(); child.write(writer); }  writer.write('<'); writer.write('/'); writer.write(this.name); writer.write('>'); } }
public void write(Writer writer) throws IOException { writeIdented(writer, 0); }
   public void write(Writer writer)      throws IOException   {      if (this.name == null) {         this.writeEncoded(writer, this.contents);         return;      }      writer.write('<');      writer.write(this.name);      if (! this.attributes.isEmpty()) {         Enumeration en = this.attributes.keys();         while (en.hasMoreElements()) {            writer.write(' ');            String key = (String) en.nextElement();            String value = (String) this.attributes.get(key);            writer.write(key);            writer.write('='); writer.write('"');            this.writeEncoded(writer, value);            writer.write('"');         }      }      if ((this.contents != null) && (this.contents.length() > 0)) {         writer.write('>');         this.writeEncoded(writer, this.contents);         writer.write('<'); writer.write('/');         writer.write(this.name);         writer.write('>');      } else if (this.children.isEmpty()) {         writer.write('/'); writer.write('>');      } else {         writer.write('>');         Enumeration en = this.enumerateChildren();         while (en.hasMoreElements()) {            XMLElement child = (XMLElement) en.nextElement();            child.write(writer);         }         writer.write('<'); writer.write('/');         writer.write(this.name);         writer.write('>');      }   }