Guest User

Untitled

a guest
Jul 13th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <tomcat-users xmlns="http://tomcat.apache.org/xml"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
  5. version="1.0">
  6. <role rolename="tomcat"/>
  7. <role rolename="manager-script"/>
  8. <role rolename="manager-gui"/>
  9. <user username="tomcat" password="tomcat" roles="tomcat"/>
  10. <user username="admin" password="admin" roles="manager-gui"/>
  11. <user username="admin1" password="admin1" roles="manager-script"/>
  12. <user username="bob" password="password" roles="apressuser"/>
  13. </tomcat-users>
  14.  
  15. In [1]: from xml.etree import ElementTree as ET
  16. In [2]: tcusers = ET.parse('tomcat-users.xml')
  17. In [3]: tcusers
  18. Out[3]: <xml.etree.ElementTree.ElementTree at 0x7fcb19434a10>
  19. In [4]: first_user = tcusers.find('./user')
  20. In [5]: first_user
  21. In [6]:
  22.  
  23. <?xml version="1.0" encoding="UTF-8"?>
  24. <tomcat-users>
  25. <role rolename="tomcat"/>
  26. <role rolename="manager-script"/>
  27. <role rolename="manager-gui"/>
  28. <user username="tomcat" password="tomcat" roles="tomcat"/>
  29. <user username="admin" password="admin" roles="manager-gui"/>
  30. <user username="admin1" password="admin1" roles="manager-script"/>
  31. <user username="bob" password="password" roles="apressuser"/>
  32. </tomcat-users>
  33.  
  34. In [7]: tcusers = ET.parse('tomcat-users.xml')
  35. In [8]: tcusers
  36. Out[8]: <xml.etree.ElementTree.ElementTree at 0x7fcb19440850>
  37. In [9]: first_user = tcusers.find('./user')
  38. In [10]: first_user
  39. Out[10]: <Element 'user' at 0x7fcb19440a10>
  40. In [12]: first_user.attrib
  41. Out[12]: {'password': 'tomcat', 'roles': 'tomcat', 'username': 'tomcat'}
Add Comment
Please, Sign In to add comment