Updated login function

Also started using libxml2
Fixed XML parser errors
Added a function to evaluate XPath expressions

Also updated error handling and comments
Cleaned up a bit