Maybe we should check the legality of xpath, otherwise the element tree will be messed up by unexpected xpath.