Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import xml.etree.ElementTree as ET
  2.  
  3.  
  4. def getText(chapter,path):
  5. tree = ET.parse(path)
  6. root = tree.getroot()
  7.  
  8. for child in root:
  9. if(child.get('number')==str(chapter)):
  10. return child.text
  11.  
  12. return ""
  13.  
  14. def getTitle(chapter,path):
  15. tree = ET.parse(path)
  16. root = tree.getroot()
  17.  
  18. for child in root:
  19. if(child.get('number')==str(chapter)):
  20. return child.get('title')
  21.  
  22. return ""
  23.  
  24. def getSubtitle(chapter,path):
  25. tree = ET.parse(path)
  26. root = tree.getroot()
  27.  
  28. for child in root:
  29. if(child.get('number')==str(chapter)):
  30. return child.get('subtitle')
  31.  
  32. return ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement