I don't work with XML often enough to have this always at the ready, so: normalize-space() will take care of chomping sequences of whitespace to a single space. So when you're trying to match something like:
<p>This is my Great Page Number Three summary </p
You can just use something like this and it will do the right thing (using dom4j if that matters):
String path = "//p[contains( normalize-space( text() ), 'This is my Great Page Number' )]"; List matching = doc.selectNodes( path );
(...and when I say 'XPath function' I actually mean 'XSLT function also used by XPath'. But since I'm just using XPath right now...)
Posted from cwinters.com; read original