Just to add my two cents to an old question, but the top rated answer seems to suggest using
simplexml_load_file("test.xml"); and then testing that a node you expect is not empty. As this would thrown a warning level error if the file is empty, I would disagree and instead wrap the call with a test for filesize.
$xmlInfo = new SplFileInfo('test.xml');
if((int) $xmlInfo->getSize() > 0)
{
$xml = simplexml_load_file($xmlInfo->getPath());
}
Of course OP has asked How can I check with PHP if a xml is empty, which doesn't specify if he means node or file, but for completeness there it is.
<?xml version="1.0"?>or an empty root-element. Thus the question from Ofir Baruch: how does the OP define "empty" in case of an XML document?