private static void writeXML( ModsInfo modsInfo, OutputStreamWriter dst, String indent, int depth ) throws IOException { Format xmlFormat = Format.getPrettyFormat(); xmlFormat.setEncoding( dst.getEncoding() ); XMLOutputter xmlOut = new XMLOutputter( xmlFormat ); writeIndent( dst, indent, depth++ ).append( "<modsinfo>\n" ); writeIndent( dst, indent, depth ); dst.append("<title>").append( xmlOut.escapeElementEntities( modsInfo.getTitle() ) ).append( "</title>\n" ); writeIndent( dst, indent, depth ); dst.append("<author>").append( xmlOut.escapeElementEntities( modsInfo.getAuthor() ) ).append( "</author>\n" ); writeIndent( dst, indent, depth ); dst.append("<threadUrl><![CDATA[ ").append( modsInfo.getThreadURL() ).append( " ]]></threadUrl>\n" ); writeIndent( dst, indent, depth++ ).append( "<versions>\n" ); for ( Map.Entry<String,String> entry : modsInfo.getVersionsMap().entrySet() ) { String versionFileHash = entry.getKey(); String versionString = entry.getValue(); writeIndent( dst, indent, depth ); dst.append( "<version hash=\"" ).append( xmlOut.escapeAttributeEntities( versionFileHash ) ).append( "\">" ); dst.append( xmlOut.escapeElementEntities( versionString ) ); dst.append( "</version>" ).append( "\n" ); } writeIndent( dst, indent, --depth ).append( "</versions>\n" ); writeIndent( dst, indent, depth ); dst.append("<threadHash>").append( modsInfo.getThreadHash() ).append( "</threadHash>\n" ); dst.append( "\n" ); writeIndent( dst, indent, depth ); dst.append( "<description>" ).append( "<![CDATA[" ); dst.append( modsInfo.getDescription() ); dst.append( "]]>\n" ); writeIndent( dst, indent, depth ); dst.append( "</description>\n" ); writeIndent( dst, indent, --depth ).append( "</modsinfo>\n" ); }