Why not just check the length of the NodeList?
if( myfile.getElementsByTagName("client").length == 0 ) { alert("no clients"); }
Add this to check if myfile has been defined
if( typeof myfile == "undefined" || myfile.getElementsByTagName("client").length == 0 ) { alert("no clients"); }
source share