Fixed a NPE if the XML document was not correctly loaded.