Fix bug in code to determine the Xpath of an element.

It wasn't working for text nodes.