1👍
✅
datei = ET.parse(settings.MEDIA_ROOT+'\\table.xml')
datas = datei.getroot()
for info in datas.findall('info'):
if info.find('Country').text == 'GERMANY':
# do whatever
pass
For more advanced stuff just read the docs at http://docs.python.org/2/library/xml.etree.elementtree.html
1👍
If you just want to know that the file contains <Country>GERMANY</Country>
, a shorter version is:
if any(i.find('Country').text == 'GERMANY' for i in datas.iterfind('info')):
print('Found It!')
- [Answered ]-Django ClearableInputField in form doesn't render in HTML
- [Answered ]-Image file cut off when uploading to AWS S3 bucket via Django and Boto3
- [Answered ]-Request.POST used by ModelForm with prefix not working with client.post in unit test
- [Answered ]-Unable to use Django Authenticate
- [Answered ]-Anymail Mailgun Error
Source:stackexchange.com