Here's the link to the API with an ID provided by another API, it should work but currently it doesn't because they have not indexed it. The problem is that link returns 200 and an empty root of xml.
I'm new-ish to Python but basically the issue is that ID returns an empty XML root, response is 200 and I can see it does return something but empty and Elementtree gives me error:
with response.text:
try:
xml = r.text
if xml:
root = ElementTree.parse(xml)
except ElementTree.ParseError:
with error: FileNotFoundError: [Errno 2] No such file or directory: '\n\n\n'
and also tried as bytes:
try:
xml = r.content
if xml:
root = ElementTree.fromstring(xml)
except ElementTree.ParseError:
with error: TypeError: Parser must be a string or character stream, not NoneType
I can't seem to trigger the catch because it's always 200. How can I check the validity/existence of the xml before parsing?
I have thousands of docs to parse and this error breaks it all.