Split the XPath handling from the real code.