in reply to How to extract text between two tags?

I would use the debugger to inspect the value of $tree and make sure it's what you expect.

Dum Spiro Spero