I'm using ElementTree to successfully pull values from specific tags in an xml file. To add some level of protection I'd like to throw and exception if a required tag is not present.
I found that ElementTree returns a value of "None" in place of a missing tag. But I can't even get that to work to my advantage :(
value = xmlTree.findtext('tag')
print value
Will print 'None" if the tag "tag" isn't present.
So I tried
if value == "None":
print "tag not present"
But for some reason it won't catch it???
My next thought was to see if ElementTree had a build in exception that would detect a missing tag, but had no luck with that either.