Thanks a lot for your help.
I understand xpaths, but I don't know how you apply them to a rtf file. Is that documented somewhere?
All the chapters in my rtf file start with a line that says "Chapter 1", etc. Just experimenting, I tried the following xpath, but it throws a conversion error if I use a star instead of a specific tag. But if I give it a specific tag, it doesn't work (since I have no idea what tag matches an arbitrary line of text).
//*[re:test(., 'chapter [0-9]*', 'i')]
|