Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. function GetName()
  2. local rootNode = xmlLoadFile("details.xml")
  3. if rootNode then
  4. local UserName = xmlFindChild(rootNode, "Username", 0)
  5. local succes = xmlNodeGetValue (UserName)
  6. if succes then
  7. return tostring(succes)
  8. end
  9. end
  10. end
  11.  
  12. function GetPassword()
  13. local rootNode = xmlLoadFile("details.xml")
  14. if rootNode then
  15. local UserName = xmlFindChild(rootNode, "Password", 0)
  16. local succes = xmlNodeGetValue (UserName)
  17. if succes then
  18. return tostring(succes)
  19. end
  20. end
  21. end
  22.  
  23. function saveDetails(username, password)
  24. local rootNode = xmlLoadFile("details.xml")
  25. if rootNode then
  26. local UserName = xmlFindChild (rootNode, "Username", 0)
  27. local Password = xmlFindChild (rootNode, "Password", 0)
  28. local succes = xmlNodeSetValue(UserName, username)
  29. local succes2 = xmlNodeSetValue(Password, password)
  30. if succes and succes2 then
  31. xmlSaveFile(rootNode)
  32. end
  33.  
  34. else
  35. local RootNode = xmlCreateFile("details.xml","Details")
  36. local NameNode = xmlCreateChild(RootNode, "Username")
  37. local PasswordNode = xmlCreateChild(RootNode, "Password")
  38. local succes3 = xmlNodeSetValue(NameNode, username)
  39. local succes4 = xmlNodeSetValue(PasswordNode, password)
  40. if succes3 and succes4 then
  41. xmlSaveFile(RootNode)
  42. end
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement