initial code work in attempt to implement #181
attempting to make xpath impl smart (unstable/tested)
tidied up code for xpath and fixed last of bugs - hopefully
Merge pull request #182 from neocotic/xpath

XPath