encodeArg( doc, value, argIter.nextElement() );
encodeArg( doc, value, argIter.next() );
  public static String encode( String methodName, Vector arguments )  {    Document doc = docBuilder.newDocument();        Element methodCallElement = doc.createElement( "methodCall" );    Element methodNameElement = doc.createElement( "methodName" );    methodNameElement.appendChild( doc.createTextNode( methodName ) );    methodCallElement.appendChild( methodNameElement );    Element params = doc.createElement( "params" );    Enumeration argIter = arguments.elements();    while ( argIter.hasMoreElements() )    {      Element param = doc.createElement( "param" );      Element value = doc.createElement( "value" );      encodeArg( doc, value, argIter.nextElement() );      param.appendChild( value );      params.appendChild( param );    }    methodCallElement.appendChild( params );    doc.appendChild( methodCallElement );    XMLSerializer xmlSerializer = null;    StringWriter strWriter = null;    OutputFormat outFormat = null;    try    {      xmlSerializer = new XMLSerializer();      strWriter = new StringWriter();      outFormat = new OutputFormat();      //outFormat.setEncoding( "UTF-8" );      outFormat.setVersion( "1.0" );      outFormat.setIndenting( false );      outFormat.setLineWidth( 0 );      outFormat.setLineSeparator( "" );      xmlSerializer.setOutputCharStream( strWriter );      xmlSerializer.setOutputFormat( outFormat );    }    catch ( Exception e )    {      e.printStackTrace();    }    try    {      xmlSerializer.serialize( doc );    }    catch ( Exception e )    {      e.printStackTrace();    }    return strWriter.toString();  }