Using XPATH expressions is faster than getElementsBy*, especially for filtering. Here is the output on my computer

Benchmark: timing 200000 iterations of DOM, XPATH...
       DOM:  8 wallclock secs ( 7.89 usr +  0.00 sys =  7.89 CPU) @ 25348.54/s (n=200000)
     XPATH:  6 wallclock secs ( 5.78 usr +  0.00 sys =  5.78 CPU) @ 34602.08/s (n=200000)
Benchmark: timing 200000 iterations of DOM2, XPATH2...
      DOM2:  7 wallclock secs ( 6.77 usr +  0.00 sys =  6.77 CPU) @ 29542.10/s (n=200000)
    XPATH2:  5 wallclock secs ( 4.98 usr +  0.00 sys =  4.98 CPU) @ 40160.64/s (n=200000)

Below is the benchmark.