Update ObjectToXml.php

Check if an object is existing and throw Exception if it is missing.