@Test public void testWrite() throws Exception { StringBuilder expected = new StringBuilder(); expected.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); expected.append( "<basic>\n" ); expected.append( " <names>\n" ); expected.append( " <name>" ).append( TRYGVIS ).append( "</name>\n" ); expected.append( " <name>" ).append( INFINITE_ARCHIVA ).append( "</name>\n" ); expected.append( " </names>\n" ); expected.append( "</basic>\n" ); DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element basic = doc.createElement("basic"); doc.appendChild(basic); Element names = doc.createElement( "names" ); basic.appendChild(names); Element name = doc.createElement("name"); name.setTextContent(TRYGVIS); names.appendChild(name); name = doc.createElement("name"); name.setTextContent(INFINITE_ARCHIVA); names.appendChild(name); StringWriter actual = new StringWriter(); XMLWriter.write( doc, actual ); assertEquals( "Comparision of contents:", expected.toString(), actual.toString() ); }
public static void write(Document doc, Writer writer) throws XMLException { write(doc, writer, false); }
XMLWriter { public static void write(Document doc, Writer writer) throws XMLException { write(doc, writer, false); } }
XMLWriter { public static void write(Document doc, Writer writer) throws XMLException { write(doc, writer, false); }  }
XMLWriter { public static void write(Document doc, Writer writer) throws XMLException { write(doc, writer, false); }  static void write(Document doc, Writer writer); static void write(Document doc, Writer writer, boolean close); }
XMLWriter { public static void write(Document doc, Writer writer) throws XMLException { write(doc, writer, false); }  static void write(Document doc, Writer writer); static void write(Document doc, Writer writer, boolean close);  }