Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xml.etree.ElementTree as ET
- import re
- flag=0
- counttree = ET.parse('countries.xml')
- countroot = counttree.getroot()
- str = "Department of Neurosurgery, University of Southern California,."
- for tokens in re.split('; |, |\.|\n',str):
- for country in countroot.findall('Country[name="'+tokens+'"]') + countroot.findall('Country[code="'+tokens+'"]'):
- cname = country.find('name').text
- flag=1
- if(flag==1):
- print("<Country>"+cname+"</Country>")
- else:
- print("<Country>-</Country>")
Add Comment
Please, Sign In to add comment