From: Peter Hickman Date: 2007-11-21T20:22:38+09:00 Subject: Re: porting java methods to ruby The simplest conversion is this: def getTextCharacters(holholderForStartAndLength) case @eventType when TEXT if @usePC holderForStartAndLength[0] = @pcStart holderForStartAndLength[1] = @pcEnd - @pcStart return @pc else holderForStartAndLength[0] = @posStart holderForStartAndLength[1] = @posEnd - @posStart return @buf end when START_TAG, END_TAG, CDSECT, COMMENT, ENTITY_REF, PROCESSING_INSTRUCTION, IGNORABLE_WHITESPACE, DOCDECL holderForStartAndLength[0] = @posStart holderForStartAndLength[1] = @posEnd - @posStart return @buf when START_DOCUMENT, END_DOCUMENT holderForStartAndLength[0] = holderForStartAndLength[1] = -1 return nil else raise "unknown text eventType: " + @eventType end end Of course this is untested and assumes that the class that defines it will also set up the various class variables (the @something in the code) and the constants (the SOMETHING in the code). You should also consider creating your own exception class for the raise. Please also read "Pounding A Nail: Old Shoe or Glass Bottle?" by Alex Papadimoulis at http://weblogs.asp.net/alex_papadimoulis/archive/2005/05/25/408925.aspx Why the hell are you not using an existing ruby xml library, you know that your's will be the slowest xml parser on earth? This endeavour is made of fail.