Fix "PHP Fatal error:  Call to a member function getElementsByTagName() on null"