I've moved this to our
testing forum since HtmlUnit is typically used for testing. Note that you will get a faster if you provide enough code to run the example. Yours doesn't even compile due to this line:
The first thing I did was try to run it. I created a file named test containing:
I then created a test program which shows this can be done with a single XPath expression (and a trim statement):